Gitter migration: Setup redirects (rollout pt. 3)
[gitter.git] / modules / presence / redis-lua / presence-eyeballs-on.lua
blob0f7319cf4d808957549c050eb6f10f23f0122070
1 local key_socket = KEYS[1];
2 local key_troupe_users = KEYS[2];
3 local key_user_lock = KEYS[3];
5 local user_id = ARGV[1];
7 local eyeball_lock = redis.call("HSETNX", key_socket, "eb", 1)
9 if eyeball_lock == 0 then
10 return { 0 }
11 end
13 redis.call("INCR", key_user_lock);
14 redis.call("EXPIRE", key_user_lock, 10);
16 local in_troupe_count = redis.call("ZINCRBY", key_troupe_users, 1, user_id)
18 return { eyeball_lock, in_troupe_count }