/luaredis

Lua built-in module implementation package hiredis implementation redis access

Primary LanguageCMIT LicenseMIT

luaredis

Copyright (c) 2013-2018 brinkqiang (brink.qiang@gmail.com)

luaredis License blog Open Source Love GitHub stars GitHub forks

Build status

Linux MacOSX Windows
lin-badge osx-badge win-badge

env

install cmake

Intro

luaredis

win

cd bin/relwithdebinfo
lua ../script/test.lua

linux

cd bin/relwithdebinfo
lua ../script/test.lua
local redis = require "luaredis"
local HOST = "127.0.0.1"
local PORT = 6379

local conn = redis.connect(HOST, PORT, 5)
if conn == nil then
  print("connect failed")  
  return 
end

local ok = redis.unwrap_reply(conn:command("AUTH", "123456"))

if ok == nil then
    print("AUTH reply: nil, type: nil")
elseif ok == "OK" then
    print("AUTH reply: " .. ok .. " type: " .. type(ok))
else
    print("AUTH reply: " .. ok .. " type: " .. type(ok))
    return
end

local info = redis.unwrap_reply(conn:command("INFO"))
print(info)
local ret = conn:command("SET", "MYKEY", "hello world!")
print(ret)
local value = conn:command("GET", "MYKEY")
print(value)

Contacts

Join the chat

Thanks