当前位置: 首页 > article >正文

redis 查找key使用正在表达式与java的区别

redis与java的正则表达式语法有些区别,需要特别注意一下。

Redis支持的正则表达式规则如下‌:

  • *:匹配任意数量的字符。
  • ?:匹配零或一个字符。
  • []:匹配指定范围内的字符‌12。

Redis中使用正则表达式的命令和示例‌:

  • KEYS pattern:该命令可以返回与指定模式匹配的所有键名。例如,KEYS user*可以获取所有以“user”开头的键‌3。
  • SCAN:这是一个迭代器命令,用于逐步遍历键空间。它支持使用正则表达式,但需要注意的是,SCAN命令本身不支持直接使用正则表达式,而是通过模式匹配来实现类似的功能。例如,SCAN 0 MATCH *pattern*可以逐步返回匹配指定模式的键‌。

Keys

Another way to iterate over the keyspace is to use the KEYS command, but this approach should be used with care, since KEYS will block the Redis server until all keys are returned.

Warning: consider KEYS as a command that should only be used in production environments with extreme care.

KEYS 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.

Supported glob-style patterns:

  • h?llo matches hellohallo and hxllo
  • h*llo matches hllo and heeeello
  • h[ae]llo matches hello and hallo, but not hillo
  • h[^e]llo matches hallohbllo, ... but not hello
  • h[a-b]llo matches hallo and hbllo

Use \ to escape special characters if you want to match them verbatim.


http://www.kler.cn/news/367653.html

相关文章:

  • 空文件夹,python项目来启动
  • 3-petalinux2018.3 摸索记录 - 命令驱动 _ 交叉编译链
  • 论文解析八: GAN:Generative Adversarial Nets(生成对抗网络)
  • csa练习1
  • 2.4_Docker与防火墙
  • 找不到包的老版本???scikit-learn,numpy,scipy等等!!
  • Linux的目录结构 常用基础命令(2)
  • Linux基础IO--重定向--缓冲区
  • 30. 串联所有单词的子串 C#实现
  • pip在ubuntu下换源
  • Android Studio超级详细讲解下载、安装配置教程(建议收藏)
  • 探索CSS动画下的按钮交互美学
  • MySQL 的元数据锁(Metadata Locks, MDL)原理详解
  • Python 协程详解----高性能爬虫
  • 适用在汽车诊断系统中的总线收发器芯片选型:CSM9241
  • Android AAR嵌套AAR打包出现问题解决方案
  • 自由学习记录(15)
  • 前端SSE-EventSource message事件执行异常问题
  • TypeScript(中)+算法(二)
  • 道可云人工智能元宇宙每日资讯|《嘉兴市推动人工智能高质量发展实施方案》发布
  • C/C++ 每日一练:二分查找
  • 【网络协议栈】Tcp协议(上)结构的解析 和 Tcp中的滑动窗口(32位确认序号、32位序号、4位首部长度、6位标记位、16为窗口大小、16位紧急指针)
  • apply call bind 简介
  • 设计模式06-结构型模式1(适配器/桥接/组合模式/Java)
  • 理解LSTM
  • 【视频混剪Demo】FFmpeg的使用【Windows】