Skip to content

Instantly share code, notes, and snippets.

@steelThread
Created December 12, 2012 02:07
Show Gist options
  • Save steelThread/4264260 to your computer and use it in GitHub Desktop.
Save steelThread/4264260 to your computer and use it in GitHub Desktop.
Little Lua script for tracking page views
local aggreate_exists = redis.call('exists', KEYS[1]);
if (aggreate_exists == 0) then
redis.call('hset', 'flushed', 0);
end
redis.call('hincrby', KEYS[1], 'visits', 1);
local uuid_exists = redis.call('hexists', KEYS[1], ARGV[1]);
if (uuid_exists == 0) then
redis.call('hset', KEYS[1], ARGV[1], nil);
redis.call('hincrby', KEYS[1], 'uniques', 1);
end
return redis.status_reply('OK');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment