Created
January 26, 2015 08:50
-
-
Save alexanderscott/cd0e43763133be27d046 to your computer and use it in GitHub Desktop.
Redis Lua script to publish a message to all SET member channels
This file contains hidden or 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
| -- @desc: Publish a message to all SET member channels | |
| -- @usage: redis-cli EVAL "$(cat SPUBLISH.lua)" 1 <setKey> <message> | |
| -- @return: number of SET member channels | |
| local function SPUBLISH(key, msg) | |
| local members = redis.call("SMEMBERS", key) | |
| for _,member in ipairs(members) do | |
| redis.call("PUBLISH", member, msg) | |
| end | |
| return #members | |
| end | |
| return SPUBLISH(KEYS[1], ARGV[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment