https://redis.io/commands/keys
demo 里面给了下面几种用法,难道是只支持这几种吗?
()|
这些都不支持吗?
h?llo matches hello, hallo and hxllo h*llo matches hllo and heeeello h[ae]llo matches hello and hallo, but not hillo h[^e]llo matches hallo, hbllo, ... but not hello h[a-b]llo matches hallo and hbllo
假设有如下 10 个 key, 怎么只获取 a1,a2,a10,a11?
redis> KEYS * 1) "a1" 2) "a2" 3) "a3" ... 10) "a10" 11) "a11"
![]() | 1 leveraging 2018-07-25 12:04:31 +08:00 a[12][012] .... |
2 yangtukun1412 2018-07-25 12:24:53 +08:00 然而这是通配符, 不是正则. |
![]() | 3 Lonely 2018-07-25 12:40:52 +08:00 via iPhone 楼主这种人直接 block。 |
![]() | 4 agagega 2018-07-25 12:53:58 +08:00 via iPhone 我印象里人家没说这是正则 |
![]() | 5 rrfeng 2018-07-25 12:56:15 +08:00 via Android rename keys "" |
![]() | 6 wwqgtxx 2018-07-25 13:10:54 +08:00 via iPhone 官方文档哪个地方说了支持正则了… |
7 CC11001100 2018-07-25 13:13:12 +08:00 搜下 redis glob |
![]() | 8 ynyounuo 2018-07-25 13:13:14 +08:00 > glob-style patterns > In computer programming, glob patterns specify sets of filenames with wildcard characters. https://www.wikiwand.com/en/Glob_(programming) |
![]() | 10 corningsun OP |
![]() | 11 caola 2018-07-25 15:22:50 +08:00 @corningsun 我从没听说过 redis 有正则,但只有一个通配符, 建议你给加上特定前缀,以后就可以通过前缀+通配符,查询这些数据 你觉得通配符还不能满足,那么建议使用 eval 来传入 lua 代码,来实现特殊的需求,查询的结果会让你满意的 |
![]() | 12 xiangyuecn 2018-07-25 15:56:02 +08:00 听人家建议生产环境慎用 keys **Warning** https://redis.io/commands/keys 相对比较少的 key 列表可以存一份到一个 set 里,一次性取出来。。一次性查很多 key 的。。用 scan ?听说的 |