lua redis Interface (Configuration lua-redis development environment at ambient ubuntu16.04)

Currently successful lua version is 5.1, according to information on the network can support display lua5.1 lua-socket

Install lua and related software:

#安装lua5.1
sudo apt install lua5.1

#安装lua-socketxiangg
sudo apt install lua-socket
sudo apt install lua-socket-dev

#安装lua-redis相关
sudo apt install lua-redis
sudo apt install lua-redis-dev

Redis installation and related software:

# Install Redis service
 sudo APT install redis- Server 

# redis client installation tools and 
sudo APT install redis-Tool

Test code test.lua:

local lu = require('luaunit')
local redis = require("redis")
local ret = 0

-- 连接本地redis服务
local cli = redis.connect("127.0.0.1",6379)


function test_set_value()
    ret = cli:set("test", "1122")
    lu.assertEquals(ret, true)
end

functiontest_get_value () 
    CLI: SET ( " some " , " 123 " ) 
    RET = CLI: GET ( " some " ) 
    lu.assertEquals (RET, " 123 " )
 End 

- using the unit testing tools 
os.exit (lu.LuaUnit. run ())

Output:

..
Ran 2 tests in 0.000 seconds, 2 successes, 0 failures
OK

Note that using unit testing tools need to add luaunit.lua file in the path

luaunit.lua Download: https://github.com/bluebird75/luaunit

~

Guess you like

Origin www.cnblogs.com/sleepylulu/p/12020715.html