Reputation: 5477
I am using Redis to store the captcha and mobile code temporarily. When I set
captcha, I use:Redis.set('captcha' + remoteIP, text);
I can see the key is captcha:127.0.0.1
in GUI manager. Redis recognized the captcha
as prefix automatically. If I use Redis.set('captcha:' + remoteIP, text)
, the key
will be captcha::127.0.0.1
.
But when I set
the code by Redis.set('code' + mobile, code);
, the actual key
is code1xxxxxxxxxx
, no prefix. I must use Redis.set('code:' + mobile, code)
then it works.
I'm using latest node_redis
client in Node.js 5.2.0.
Upvotes: 0
Views: 3878
Reputation: 141829
Your variable remoteIP
already contains a :
. Redis didn't recognize captcha was a prefix and add a colon, it was just told to use whatever the expression 'captcha' + remoteIP
evaluated to as a key, in this case that was captcha:127.0.0.1
, since remoteIP === ':127.0.0.1
.
Upvotes: 3