--
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.
local key= KEYS[1]
local value = ARGV[1]
local expiry = ARGV[2]
local valueFieldName= "data"
local expiryFieldName = "originalExpiry"
redis.call("HMSET", key, valueFieldName, value, expiryFieldName, expiry)
redis.call("EXPIRE", key, expiry)
"""
This stores both the original expiry and the value together in a hash, and sets the expiry.
SlidingExpireGETScript = """local key= KEYS[1]
local valueFieldName= "data"
local expiryFieldName = "originalExpiry"local value = redis.call("HGET", key, valueFieldName)
local originalExpiry = redis.call("HGET", key, expiryFieldName)redis.call("EXPIRE", key, originalExpiry)
return value
"""This second script will pull the original expire value the first script stored and reset it before returning the item. I haven't tested this, and you might need a bit more error checking to handle edge cases for things like the key having already expired, but I hope that helps if you want to go down this route.
This should be as efficient as a native solution for all practical purposes. (Nothing here would be at all cpu bound, so the little bit of overhead from lua shouldn't have any noticeable impact vs a native solution)
--
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 Developer Advocate
Redis Watch Newsletter | Curator and Janitor
Redis Labs | ~ of Redis
Mobile: +1 (415) 688 2443
Office: +1 (650) 461 4652
Mobile (IL): +972 (54) 567 9692
Office (IL): +972 (3) 720 8515 Ext. 123
Email: ita...@redislabs.com
Twitter: @itamarhaber
Skype: itamar.haber
Oh, true, jumped to conclusions without reading - sorry :)
And after reading it, your approach rules.