Hello AllWe are looking to use redis for one of our use cases wherein we need to SCAN a large number of "rows" with MATCH, and, return the result set. This needs to be done as efficiently as possible as we must keep the latencies really low.
As an example, we may scan up to a million rows and potentially half of those could match the criteria.Following is how the script looks like at a high level. Would highly appreciate any recommendations/suggestions to achieve this with the best possible performance. Few context sensitive questions have been embedded as comments in the code below. Some other questions are given at the end.
---------LUA Start-----------local all_keys = {};local t = {};local done = false;local cursor = "0"local value = "";local val = "";repeatlocal result = redis.call("SCAN", cursor, "MATCH", ARGV[1], "count", ARGV[2])cursor = result[1];t = result[2];for i,key in pairs(t) dovalue = redis.call("HMGET",key,"field1","field2","field3","field4","field5")if value[1] == "true" then-- Q1) Is setting a matched row in a LUA table more efficient than setting it in a redis key (for example, in a hashmap using HMSET)? Currently, the following command seems to be the main performance bottleneck.
all_keys[key] = valueendendif cursor == 0 thendone = true;enduntil done-- Q2) What would be the implications of returning a huge result set? Persisting result set in redis key
return all_keys---------LUA End-----------Q3) LUA best practice suggests having scripts as small as possible. What would be an optimal breakup of this script?
I am getting back to Redis after a long gap. So my apologies for any ignorance.
--RegardsNeelesh
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 - Curator 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