Redis 或签入 MATCH [英] Redis OR check in MATCH

查看:70
本文介绍了Redis 或签入 MATCH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为初学者,我想知道是否有办法在redis中编写下面的查询

As a beginner, I would like to know if there is a way to write below query in redis

Scan 0 MATCH Test:[keyword*:* | *:keyword]

现在我必须对这个查询进行两次单独的扫描,如下所示

Right now I have to do two separate scans for this query as below

Scan 0 MATCH Test:*:keyword*
Scan 0 MATCH Test:keyword*:*

推荐答案

我看到您在这里有 3 个选择:

I see that you've 3 choices here:

  1. 将两个命令包装到一个 Lua 脚本中,并像调用单个命令一样调用它.

  1. Wrap both commands into a Lua script and call it as it would be a single command.

不要扫描,而是索引.创建一个 setsorted set,您将在其中存储与这些模式匹配的所有元素,然后执行 aa sscanzscan 没有 MATCH.

Instead of scanning do indexing. Create a set or sorted set where you'll store all elements that matches these patterns, and just perform a a sscan or zscan with no MATCH.

继续做你已经做过的事情.

Keep doing it as you've done already.

这篇关于Redis 或签入 MATCH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆