performance - Possible with lua in redis to return all key stored in a set as a list of hashes? -
i have structure
data_type:key1 - hash data_type:key2 - hash data_type:key3 - hash data_type:key4 - hash data_type:key5 - hash data_type:index - set(key1, key2, key3, key4, key5)
is possible lua in redis build script iterate on set data_type:index , return data_type:key*'s list of hashes? still learning lua go in head think work like
collect = [] key_name in redis.call.smemembers('data_type:index'): collect.append( redis.call.smembers('data_type:' + key_name) return collect
generally of index's have 100 keys, each key 1kb, script have 100-120kb response size under ideal circumstances.
and before asks, real keys 'some_data:status:{64 bit hex string}' , 'some_data:index:2013:05:09' {64 bit hex string} being member of :index set.
check sscan command.
something following should work in case:
local collect = {} local match_pattern = "*" local results = redis.call("sscan", "data_type:index", 0, "match", match_pattern) i, key_name in ipairs(results[2]) -- code here (could different depending on needs) local key_value = redis.call("get", "data_type:" .. key_name) if key_value table.insert(collect, key_value) end end return collect
Comments
Post a Comment