开发者

Searching for values in Redis

开发者 https://www.devze.com 2023-03-29 18:24 出处:网络
Is it possible to search for occurrences of a specific value in redis? 开发者_如何学Go It\'s easy enough to do the same for keys

Is it possible to search for occurrences of a specific value in redis?

开发者_如何学Go

It's easy enough to do the same for keys

SET firstname "John"

KEYS f?rstname
["firstname"]

But can one search for all occurrences of "John" or better yet "J*hn" ?


As far as I know there is no such option in Redis. As you mentioned KEYS pattern can be used to search for the keys with specific pattern, but similar functionality on values would result into search among all of the keys/fields/elements which may not be trivial since Redis has advanced data structures like hashes, sets and lists. Time complexity of this operation would be possibly even greater than O(N) which is why also KEYS command shouldn't be used in production environments.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号