在redis中检查一个键是否具有特定值

我需要在哈希表中特定地检查某个键。

例如:HMSET myhash field1 "Hello" field2 "HI" field3 "Hey"

现在,我想要检查field3是否具有值“Hey”。

点赞
用户204011
用户204011

在 Lua 脚本中?你可以像这样做:

如果 redis.call("hget", "myhash", "field3") == "Hey" then
    -- do what you want
end
2014-07-21 21:25:00