Skip to content

Instantly share code, notes, and snippets.

@fritzy
Last active April 19, 2017 21:10
Show Gist options
  • Save fritzy/7426219 to your computer and use it in GitHub Desktop.
Save fritzy/7426219 to your computer and use it in GitHub Desktop.
Update a key, send out a notice, and log the notice.
--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