SCAN和KEYS 区别

来源:互联网 发布:高级宏观经济学 知乎 编辑:程序博客网 时间:2024/06/06 18:33
Warning: consider KEYS as a command that should only be used in production environments with extreme care. It may ruin performance when it is executed against large databases. This command is intended for debugging and special operations, such as changing your keyspace layout. Don’t use KEYS in your regular application code. If you’re looking for a way to find keys in a subset of your keyspace, consider using SCAN or sets.警告;考虑KEYS 作为一个命令行用于生产环境需要非常小心。它可以破坏性能当它是被执行在大的数据库上,这个命令是用于调试和指定的操作,比如改为你的keyspace 的位置。不要使用KEYS 在你的常规应用程序。如果你寻找一种方式来找到keys 在你的keyspace的子集,考虑或者SCAN 或者sets[root@node01 ~]#  redis-cli -a 'r,uLgt.313' --scana4a1a5user1foouser2listwangpinset-keykeyhash-keybbaaaa6a3mycounter注意 head -10 是用于为只打印头几行。Scanning 是可以使用底层的模式匹配SCAN 命令的能力 使用--pattern option.[root@node01 ~]#  redis-cli -a 'r,uLgt.313' --scan --pattern 'a*'a4a1a5aaaa6a3