如何检查散列中的密钥是否存在(redis)?
问题描述:
如何检查散列中的密钥是否存在(redis)?如何检查散列中的密钥是否存在(redis)?
我试着这样说:
redisClient.exists(obj.mydict.user.toString().pos, function(err,reply) {
if(!err) {
if(reply !== null) {
...
但我得到:
node_redis: Deprecated: The EXISTS command contains a "undefined" argument.
This is converted to a "undefined" string now and will return an error from v.3.0 on.
Please handle this in your code to make sure everything works as you intended it to.
我不知道怎么办。我正在尝试检查我的.pos密钥是否存在于我的散列表obj.mydict.user.toString(),它将如何在node_redis?
答
如何使用?
var hash = {'a': 1, 'b': 2};
console.log('a' in hash);
console.log('c' in hash);
所以,这样我做了,但是我不得不搜索redis中的所有散列,我只是想检查银行中是否有密钥。从我在这里看到的文档中看到的 – PerduGames
,似乎没有。所以方法是:'redisClient.hgetall(obj.mydict.user.toString(),function(err,reply){if(!err){if(“pos”in reply){...' – PerduGames