Example:
email = "foo...@foo.com"
username = "fooguy"
userdata = some_hash.to_json
# For cases when I have the username only
redis.set "user:#{username}", userdata
# For cases where I have the email only
redis.set "user:by-email:#{email}", userdata
The problem with this is 2 fold:
1. I'm duplicating data which duplicates memory consumption
2. I need to be sure to delete both keys when I delete the user
What I'm proposing is:
redis.alias "user:#{username}", "user:by-email:#{email}"
and to push my luck a little further:
redis.delete "user:#{username}" will remove all dependent aliases
I understand I can just do multiple lookups .. i.e.
username = redis.get "user:by-email:#{email}"
userdata = redis.get "user:#{username}"
but this means an extra call, which feels like clutter, and another key to track
when deletion comes around.
Is this something that is possible to get into redis? Am I insane/lazy?
--
Blake Mizerany
blake.m...@gmail.com
Cheers,
Pieter
> --
> You received this message because you are subscribed to the Google Groups
> "Redis DB" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/redis-db/-/TGpZqqNs-M8J.
> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to
> redis-db+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/redis-db?hl=en.
Good reasons, really, and an interesting idea regarding the Lua interface. I'll keep this in mind, thanks!