gpt4 book ai didi

redis - 如何使用键与 express 列表不匹配的正则表达式删除 redis?

转载 作者:可可西里 更新时间:2023-11-01 11:32:38 25 4
gpt4 key购买 nike

我尝试在redis中删除行,我首先搜索键以确保我的表达是正确的。

获取以 sess: 开头的键:

keys sess:*   //I get return as I expect

获取不以 sess: 开头的键:

keys ^(sess:)* //I get empty list, not as expect
keys [^sess:]* //I get list that not start with s or e or :, not as expect

获取不以sess:brand:开头的key

keys [^(sess:|brand:)]* //I get list that not start with s or e or : or b and so on, not as expect

谁能帮我列出我没有得到预期正确返回的 list ?

最佳答案

如果您要引用keys 命令的文档 here你会注意到参数

Supported glob-style patterns: 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 Use \ to escape special characters if you want to match them verbatim.

因此不支持正则表达式

如文档中所述:

If you're looking for a way to find keys in a subset of your keyspace,consider using SCAN or sets

Link to glob-style patterns here

关于redis - 如何使用键与 express 列表不匹配的正则表达式删除 redis?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38882222/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com