Last active
April 19, 2017 21:10
-
-
Save fritzy/7426219 to your computer and use it in GitHub Desktop.
Update a key, send out a notice, and log the notice.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--2 key changelog update millisecond-epoch | |
local key, changelog = unpack(KEYS); | |
local update, epoch = unpack(ARGV); | |
local result = redis.call('SET', key, update); | |
local notice = cjson.encode({key = key, value = update, time = epoch}); | |
redis.call('ZADD', changelog, epoch, notice); | |
redis.call('ZREMRANGEBYSCORE', changelog, '-inf', epoch - 86400000); | |
redis.call('PUBLISH', changelog, notice); | |
return result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment