gpt4 book ai didi

node.js - 在 Redis 中设置键前缀的正确方法是什么?

转载 作者:可可西里 更新时间:2023-11-01 11:11:49 25 4
gpt4 key购买 nike

我正在使用 Redis 临时存储验证码和移动代码。当我设置验证码时,我使用:Redis.set('captcha' + remoteIP, text);

我可以在 GUI 管理器中看到 key 是 captcha:127.0.0.1。 Redis 自动将 captcha 识别为前缀。如果我使用 Redis.set('captcha:' + remoteIP, text)key 将是 captcha::127.0.0.1

但是当我通过Redis.set('code' + mobile, code);set代码时,实际的keycode1xxxxxxxxxx,无前缀。我必须使用 Redis.set('code:' + mobile, code) 然后它才能工作。

我在 Node.js 5.2.0 中使用最新的 node_redis 客户端。

最佳答案

您的变量 remoteIP 已经包含一个 :。 Redis 没有识别出验证码是一个前缀并添加了一个冒号,它只是被告知使用表达式 'captcha' + remoteIP 评估为键,在这种情况下是 captcha :127.0.0.1,因为 remoteIP === ':127.0.0.1

关于node.js - 在 Redis 中设置键前缀的正确方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35789420/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com