Redis命令获取所有可用密钥? [英] Redis command to get all available keys?

查看:163
本文介绍了Redis命令获取所有可用密钥?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有Redis命令用于获取数据库中的所有密钥?我已经看到一些python-redis库正在获取它们.但是我想知道从redis-client是否有可能.

Is there a Redis command for fetching all keys in the database? I have seen some python-redis libraries fetching them. But was wondering if it is possible from redis-client.

推荐答案

尝试查看 KEYS 命令. KEYS *将列出存储在Redis中的所有密钥.

Try to look at KEYS command. KEYS * will list all keys stored in redis.

编辑:请注意KEYS文档页面顶部的警告:

please note the warning at the top of KEYS documentation page:

时间复杂度:,假设数据库中的密钥名称和给定模式的长度有限,则O(N)以N为数据库中密钥的数量.

Time complexity: O(N) with N being the number of keys in the database, under the assumption that the key names in the database and the given pattern have limited length.

更新(V2.8或更高版本): SCAN KEYS的更好替代品,因为它既不会阻塞服务器,也不会消耗大量资源.优先使用它.

UPDATE (V2.8 or greater): SCAN is a superior alternative to KEYS, in the sense that it does not block the server nor does it consume significant resources. Prefer using it.

这篇关于Redis命令获取所有可用密钥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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