0

I'm trying to implement some bitwise operation on keys in redis. I have to store let's say key value 12:CA foo 12:US bar 42:CA tag

And I'm trying to be able to query all with CA or all with 12 Is this even possible ?

Thanks

1 Answer 1

0

I may be mis-interpreting the question, but if you have key => values like

12:CA => foo
12:US => bar
42:CA => tag

And you want to pull all keys matching CA, or 12, then you can just use the keys operator along with a wildcard

keys *:CA
keys 12:*

NOTE This only returns the matching keys. To get the values, you need to use the returned keys.

Sign up to request clarification or add additional context in comments.

3 Comments

Oh really ?? I really didn't know I could use wildcard like that ! You truly made my day thanks !
Another note: Using the wildcard can be extremely slow. If your data model will allow it, and your number of keys will get large, you might want to consider using a Hash instead.
Yes I thought about this ... I'm gonna have a serious performance issue ... I'm gonna rechek my model but I'm pretty sure I'm gonna have a large set of data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.