Since | Origin / Contributor | Maintainer | Source |
---|---|---|---|
2015-02-06 | Vladimir Dronnikov | Vladimir Dronnikov | redis.lua |
This Lua module provides a simple implementation of a Redis client.
redis = dofile("redis.lua")
redis = nil
Function used to connect to Redis server.
redis.connect(host, [port])
host
: Redis host name or addressport
: Redis database port. Default value is 6379.Object with rest of the functions.
Subscribe to a Redis channel.
redis:subscribe(channel, handler)
channel
: Channel namehandler
: Handler function that will be called on new message in subscribed channelnil
Publish a message to a Redis channel.
redis:publish(channel, message)
channel
: Channel namemessage
: Message to publishnil
Unsubscribes from a channel.
redis:unsubscribe(channel)
channel
: Channel name to unsubscribe fromnil
Function to close connection to Redis server.
redis:close()
None
nil
local redis = dofile("redis.lua").connect(host, port)
redis:publish("chan1", foo")
redis:subscribe("chan1", function(channel, msg) print(channel, msg) end)