Is it possible to use Redis to lookup by key OR value? I need to store a master list of email addresses, assign a UUID to each address, but be able to find the ID OR ADDRESS by using the other piece of data. I cannot find a definitive "yes" or "no." Any examples would be appreciated.
You'll want to create 2 hashmaps:
For example:
> hset uuid_to_email 39315120-9581-11e3-9c4e-0002a5d5c51b [email protected]
> hset email_to_uuid [email protected] 39315120-9581-11e3-9c4e-0002a5d5c51b
Then to retrieve the value, use the hashmap that maps from the value you have. If you have a UUID, use uuid_to_email:
> hget uuid_to_email 39315120-9581-11e3-9c4e-0002a5d5c51b
"[email protected]"
If you have an email, use email_to_uuid:
> hget email_to_uuid [email protected]
"39315120-9581-11e3-9c4e-0002a5d5c51b"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With