ruby redis 客户端扫描 vs 密钥 [英] ruby redis client scan vs keys

查看:67
本文介绍了ruby redis 客户端扫描 vs 密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 redis 的 ruby​​ 客户端寻找一些文档,但不幸的是.我正在使用密钥,但我听说它们在生产 redis 中的表现很糟糕.

$redis = Redis.new(host: Settings.redis_host, port: Settings.redis_port)keys = $redis.keys("前缀*")

想切换到 $redis.scan("prefix*") 但我没有找到任何例子.也试过了

keys = $redis.scan(0, {match: "key:1?"})Redis::CommandError: ERR 语法错误keys = $redis.scan(0, match: "key:1?")Redis::CommandError: ERR 语法错误

对此有一点了解.谢谢.

将 redis 客户端从 3.0.4 更新到 3.0.7 后

keys = $redis.scan(0, match: "prefix*")

工作.

解决方案

这样做:

keys = $redis.scan(0, match: 'prefix?')

这里是文档"您需要.

请务必同时阅读SCAN官方文档.>

I am looking for some documentation for the ruby client for redis with no luck. I am using keys, but I've heard their performance in production redis is terrible.

$redis = Redis.new(host: Settings.redis_host, port: Settings.redis_port)
keys = $redis.keys("prefix*")

Want to switch to $redis.scan("prefix*") but I didn't find any examples for it. also tried

keys = $redis.scan(0, {match: "key:1?"})
Redis::CommandError: ERR syntax error
keys = $redis.scan(0, match: "key:1?")
Redis::CommandError: ERR syntax error

appreciate a little light on this. Thanks.

Edit: After updating the redis client from 3.0.4 to 3.0.7 the

keys = $redis.scan(0, match: "prefix*")

worked.

解决方案

Do it like this:

keys = $redis.scan(0, match: 'prefix?')

Here is the "documentation" you need.

Be sure to also read the official documentation of SCAN.

这篇关于ruby redis 客户端扫描 vs 密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆