get all hashes sorted from a redis server

2,647 views
Skip to first unread message

Quentin

unread,
Mar 21, 2011, 6:53:38 PM3/21/11
to Redis DB
Hello,
I have a redis server, with N user hashes, for instance :

user_12354: {name: "aname", mail: "amail", password: "apassword"}
...

I'd like to get all this hashes in 1 request. Is it possible ?
Can we directly create a list of hashes and get all of them in just 1
request (not N) ? I didn't found any instruction to do so in the
command list.
If it's possible, can we get all the result of this list of hashes,
using the SORT command on the hashes fields ?

For now, the only solution I found is to create a list with the hash
ID as value, and then to use the SORT command on this list to directly
get the result :
SORT mylist BY user_* by user_*->mail, user_*->name GET user_*

Is there a cleverer to do that (just 1 list of hash for instance) ?

Thanks for you help

Quentin

Jonathan Leibiusky

unread,
Mar 21, 2011, 7:03:40 PM3/21/11
to redi...@googlegroups.com, Quentin
One way to do that is how you mentioned using the SORT command.
But I would say that the best one would be using a pipeline and sending multiple HGETALL.
Pipelining in redis is FAST


--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
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.


Quentin

unread,
Mar 21, 2011, 7:18:59 PM3/21/11
to Redis DB
Thanks for the tip, but since my app doesn't know all my users id, I
assume I still need to have a list which stores the hashes id, fletch
it and get the hashes value using pipelining. I'll give it a try.
So no built-in "list of hashes" ?


On Mar 22, 12:03 am, Jonathan Leibiusky <ionat...@gmail.com> wrote:
> One way to do that is how you mentioned using the SORT command.
> But I would say that the best one would be using a pipeline and sending
> multiple HGETALL.
> Pipelining in redis is FAST
>

tribalvibes

unread,
May 10, 2011, 5:32:13 PM5/10/11
to Redis DB
What is wrong with using the SORT method as you described, other than
perhaps needlessly sorting the hashes before returning them (and
couldn't you use the 'nosort' option of SORT?) Does the GET user_*
properly return all fields of every hash referenced by the list?

Am I the only one who finds the concrete instruction set of Redis
rather annoying, as it must be for the developers to keep thinking of
mnemonics for new operations, and for client library maintainers. Why
couldn't plain MGET key, key, ... work polymorphically for all data
types, not just string values? And also accept an offset and limit?
What about maintaining sorted lists with O(log(N)) operations for
insert that are able to reference hash keys? e.g.,

LINSERT theList by user_*->name newUserId
Reply all
Reply to author
Forward
0 new messages