-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
redis presence code/layout improvements (#322)
- Loading branch information
Showing
4 changed files
with
87 additions
and
55 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- Add/update presence information. | ||
-- KEYS[1] - presence set key | ||
-- KEYS[2] - presence hash key | ||
-- ARGV[1] - key expire seconds | ||
-- ARGV[2] - expire at for set member | ||
-- ARGV[3] - client ID | ||
-- ARGV[4] - info payload | ||
redis.call("zadd", KEYS[1], ARGV[2], ARGV[3]) | ||
redis.call("hset", KEYS[2], ARGV[3], ARGV[4]) | ||
redis.call("expire", KEYS[1], ARGV[1]) | ||
redis.call("expire", KEYS[2], ARGV[1]) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- Get presence information. | ||
-- KEYS[1] - presence set key | ||
-- KEYS[2] - presence hash key | ||
-- ARGV[1] - current timestamp in seconds | ||
local expired = redis.call("zrangebyscore", KEYS[1], "0", ARGV[1]) | ||
if #expired > 0 then | ||
for num = 1, #expired do | ||
redis.call("hdel", KEYS[2], expired[num]) | ||
end | ||
redis.call("zremrangebyscore", KEYS[1], "0", ARGV[1]) | ||
end | ||
return redis.call("hgetall", KEYS[2]) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- Remove client presence. | ||
-- KEYS[1] - presence set key | ||
-- KEYS[2] - presence hash key | ||
-- ARGV[1] - client ID | ||
redis.call("hdel", KEYS[2], ARGV[1]) | ||
redis.call("zrem", KEYS[1], ARGV[1]) |
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