redis key模糊查找

Posted Caesar_the_great

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了redis key模糊查找相关的知识,希望对你有一定的参考价值。

https://blog.csdn.net/zhaipengfei1231/article/details/80819454?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-6.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-6.nonecase

https://blog.csdn.net/honer123/article/details/79698828?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-1.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-1.nonecase

*:通配任意多个字符

?:通配单个字符

[]:通配括号内的某一个字符

returnstringRedisTemplate.keys("*"+ pattern + "*");

return stringRedisTemplate.keys("?" + pattern);

return stringRedisTemplate.keys("[" + pattern + "]");

 

127.0.0.1:6379> keys *ge
1) "vge"
2) "sge"
3) "zge"
4) "age"
127.0.0.1:6379> keys *e
1) "vge"
2) "sge"
3) "name"
4) "zge"
5) "age"
6) "namee"
7) "allSeedName"
127.0.0.1:6379> keys ?e
(empty list or set)
127.0.0.1:6379> keys ?ge
1) "vge"
2) "sge"
3) "zge"
4) "age"
127.0.0.1:6379> keys ???
1) "vge"
2) "sge"
3) "www"
4) "zge"
5) "age"

以上是关于redis key模糊查找的主要内容,如果未能解决你的问题,请参考以下文章

redis key模糊查找

redis 怎样查找一个key?

redis 怎样查找一个key?

Redis模糊匹配删除key

Redis Keys 命令 - 查找所有符合给定模式( pattern)的 key

Redis-Jedis使用Scan实现redis前缀key查找