I have two lists in Redis. How can I check those lists are equal? Is the only option is to get elements from the list one-by-one and compare to the list in memory?
Is Redis provide any workarounds?
Thanks,
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.
Itamar Haber | Chief OSS Education Officer
Redis Labs ~/redis
Mobile: +972 (54) 567 9692
Email: ita...@redislabs.com
Twitter: @itamarhaber
Skype: itamar.haber
^ redis.call('DUMP',KEYS[1]) == redis.call('DUMP',KEYS[2]) then
On Wed, Mar 15, 2017 at 1:01 PM, Itamar Haber <ita...@redislabs.com> wrote:
There are no workarounds, Redis has no digest function for Lists (or other data types for that matter) and since these are doubly-linked there's no other way to compare them other than element by element.You could make the comparison in Lua however, to make it more efficient compared to performing it client-side. Something like the following should work:if redis.call('LLEN',KEYS[1]) == redis.call('LLEN', KEYS[2]) andredis.call('LRANGE',KEYS[1],0,0) == redis.call('LRANGE',KEYS[2],0,0) andredis.call('LRANGE',KEYS[1],-1,-1) == redis.call('LRANGE',KEYS[2],-1,-1) andredis.call('DUMP',KEYS[1]) == redis.call('DUMP',KEYS[1]) thenreturn 'Lists are the same'endreturn 'Lists are not the same'A module-based implementation is likely to be faster - there's the https://github.com/redislabsmodules/redex/ repo that is the perfect place to open an FR/PR to ;)
On Wed, Mar 15, 2017 at 12:49 PM, Marc Gravell <marc.g...@gmail.com> wrote:
This is probably a bad idea, but you could check that "DUMP x" gives the same result as "DUMP y" - however, you should note that the "DUMP" format is opaque and doesn't explicitly offer any guarantees other than it will work with RESTORE.This *might* be something that you could add via a module? (I'm not saying it would be trivial or efficient)
On 15 March 2017 at 10:29, prabhakaran s <prabhak...@gmail.com> wrote:
I have two lists in Redis. How can I check those lists are equal? Is the only option is to get elements from the list one-by-one and compare to the list in memory?
Is Redis provide any workarounds?
Thanks,
--
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 https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.
--Regards,
Marc
--
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 https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.
--Itamar Haber | Chief OSS Education Officer
Redis Labs ~/redisMobile: +972 (54) 567 9692
Email: ita...@redislabs.com
Twitter: @itamarhaber
Skype: itamar.haber
There are no workarounds, Redis has no digest function for Lists (or other data types for that matter) and since these are doubly-linked there's no other way to compare them other than element by element.You could make the comparison in Lua however, to make it more efficient compared to performing it client-side. Something like the following should work:if redis.call('LLEN',KEYS[1]) == redis.call('LLEN', KEYS[2]) andredis.call('LRANGE',KEYS[1],0,0) == redis.call('LRANGE',KEYS[2],0,0) andredis.call('LRANGE',KEYS[1],-1,-1) == redis.call('LRANGE',KEYS[2],-1,-1) andredis.call('DUMP',KEYS[1]) == redis.call('DUMP',KEYS[1]) thenreturn 'Lists are the same'endreturn 'Lists are not the same'A module-based implementation is likely to be faster - there's the https://github.com/redislabsmodules/redex/ repo that is the perfect place to open an FR/PR to ;)
On Wed, Mar 15, 2017 at 12:49 PM, Marc Gravell <marc.g...@gmail.com> wrote:
This is probably a bad idea, but you could check that "DUMP x" gives the same result as "DUMP y" - however, you should note that the "DUMP" format is opaque and doesn't explicitly offer any guarantees other than it will work with RESTORE.This *might* be something that you could add via a module? (I'm not saying it would be trivial or efficient)
On 15 March 2017 at 10:29, prabhakaran s <prabhak...@gmail.com> wrote:
I have two lists in Redis. How can I check those lists are equal? Is the only option is to get elements from the list one-by-one and compare to the list in memory?
Is Redis provide any workarounds?
Thanks,
--
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 https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.
--Regards,
Marc
--
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 https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+unsubscribe@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+unsubscribe@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.