redis-lua is a pure Lua client library for the Redis advanced key-value database.
- Support for Redis up to version 1.2
- Command pipelining
- User-definable commands
require 'redis'
local redis = Redis.connect('127.0.0.1', 6379)
local response = redis:ping() -- true
redis:set('usr:nrk', 10)
redis:set('usr:nobody', 5)
local value = redis:get('usr:nrk') -- 10
for _,v in ipairs({ 10,3,2,6,1,4,23 }) do
redis:push_tail('usr:nrk:ids',v)
end
local sorted = redis:sort('usr:nrk:ids', {
sort = 'asc', alpha = true, limit = { 1, 5 }
}) -- {1=10,2=2,3=23,4=3,5=4}
for k,v in pairs(redis:info()) do
print(k .. ' => ' .. tostring(v))
end
--[[
changes_since_last_save => 8
role => master
last_save_time => 1275138868
used_memory => 4735076
bgsave_in_progress => 0
redis_version => 1.2.6
multiplexing_api => epoll
used_memory_human => 4.52M
uptime_in_seconds => 3451
connected_slaves => 0
connected_clients => 1
bgrewriteaof_in_progress => 0
db10 => table: 0x864e020
arch_bits => 32
total_commands_processed => 601082
db0 => table: 0x8652030
total_connections_received => 20
uptime_in_days => 0
]]
- Lua 5.1 or LuaJIT 2.0
- LuaSocket 2.0
- Telescope (required to run the test suite)
The code for redis-lua is distributed under the terms of the MIT/X11 license (see LICENSE).