Ordering of redis values when using hvals

135 views
Skip to first unread message

Sridhar Iyer

unread,
Jan 29, 2015, 12:12:03 AM1/29/15
to redi...@googlegroups.com
Hi all,

I'm using HMSET to store some values in redis, and then using HVALS to get the values in order. However if one of the values entered is longer, the ordering is no longer honored. Is there a way to get around this issue:

127.0.0.1:6379[1]> hmset abc3 "tag" "1111111" "hset" "22222222222222222222222222222222" "ncounters"  "3" "counters" "44444444444444444444444444444444444444444444444444444444444555:44444444444444444444444444444444444444444444444444444444444555:" "ckey" "5555555"
OK
127.0.0.1:6379[1]> hvals abc3
1) "22222222222222222222222222222222"
2) "44444444444444444444444444444444444444444444444444444444444555:44444444444444444444444444444444444444444444444444444444444555:"
3) "3"
4) "1111111"
5) "5555555"



if the "444...." string is smaller, I get the values in order. Redis documentation says that strings should be less that 512MB which this obviously is. 
Any pointers would be helpful.

Regards,
Sridhar

(I'm using redis-cli 2.8.17 on ubuntu 12.04 3.5.0-54 compiled on 64 bit).

Itamar Haber

unread,
Jan 29, 2015, 4:00:13 AM1/29/15
to redi...@googlegroups.com
Redis Hashes do not provide an internal order and HVALS' reply sorting isn't guaranteed. If you need the values from a Hash sorted, you can use a Lua script or do the sorting in the application. 

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at http://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.



--

Itamar Haber | Chief Developers Advocate
Redis Watch Newsletter - Editor and Janitor
Redis Labs - Enterprise-Class Redis for Developers

Mobile: +1 (415) 688 2443
Mobile (IL): +972 (54) 567 9692
Email: ita...@redislabs.com
Skype: itamar.haber

Blog  |  Twitter  |  LinkedIn


Sridhar Iyer

unread,
Jan 29, 2015, 1:30:56 PM1/29/15
to redi...@googlegroups.com
Ok thanks. 
I had my application depend on the insertion order of HSET to get HVALS back in the same order. I guess now my application has to do a HGETALL and then do a string compare to assign value to the proper struct attribute :(

Regards,
Sridhar
Reply all
Reply to author
Forward
0 new messages