Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moteus/lua-lluv-redis
Redis client for lua-lluv library
https://github.com/moteus/lua-lluv-redis
async lua redis
Last synced: 28 days ago
JSON representation
Redis client for lua-lluv library
- Host: GitHub
- URL: https://github.com/moteus/lua-lluv-redis
- Owner: moteus
- License: mit
- Created: 2015-03-15T07:24:23.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-09-18T08:08:31.000Z (about 5 years ago)
- Last Synced: 2024-10-05T06:39:46.983Z (about 1 month ago)
- Topics: async, lua, redis
- Language: Lua
- Homepage:
- Size: 117 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lua-lluv-redis
[![Licence](http://img.shields.io/badge/Licence-MIT-brightgreen.svg)](LICENSE)
[![Build Status](https://travis-ci.org/moteus/lua-lluv-redis.svg?branch=master)](https://travis-ci.org/moteus/lua-lluv-redis)
[![Coverage Status](https://coveralls.io/repos/moteus/lua-lluv-redis/badge.svg)](https://coveralls.io/r/moteus/lua-lluv-redis)## Usage
### lluv client
```Lua
local cli = redis.Connection.new()
cli:open(function(cli)
cli:ping(print)
cli:quit(print)
end)
```### basic transaction
```Lua
cli:open(function()
cli:multi(function(cli, err, data) -- begin transaction
-- We can cat IO/redis error
-- if we get redis error that means application error
-- try nested transaction or transaction in SUBSCRIBE mode
-- so application shoul fix it.
assert(not err or err:cat() ~= 'REDIS')
end)-- we can proceed each command in separate callback
cli:set("a", "10", function(cli, err, data)
print("SET:", data)
end)cli:ping() --or we can ignore callback
cli:exec(function(cli, err, res) -- end transaction
-- and proceed all results in transaction
for k, v in ipairs(res) do print("CMD #" .. k, v) end
end)cli:quit()
end)
```### pipeline
```lua
-- new pipeline
p = cli:pipeline()
:set(a, 10)
:set(b, 20)-- execute and preserve pipeline
p:execute(true)-- append command
p:set(c, 30)-- and execute it again
p:execute() -- execute and clearp -- set new commands and execute
:set(a, 20)
:set(b, 30)
:execute()
```