How to count the number of keys matching a pattern?

前端 未结 5 489
忘了有多久
忘了有多久 2021-01-31 13:35

How can I find the count of all the keys that has a matching pattern.

For example, there are two keys abc:random-text-1 and abc:random-text-2 .

5条回答
  •  爱一瞬间的悲伤
    2021-01-31 14:16

    From here:

    eval "return #redis.pcall('keys', 'abc:*')" 0
    

    It's not O(1), but at least the count is done on the server side.

提交回复
热议问题