-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtests.lua
More file actions
49 lines (35 loc) · 1.11 KB
/
tests.lua
File metadata and controls
49 lines (35 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
local mem = require 'lua-libmemcached'
local function simple_table_dump(...)
local tb, arg = ...
if arg then print(arg) end
for k,v in pairs(tb) do
print(string.format(' [%s] = %s', tostring(k), tostring(v)))
end
end
local inst = mem.new("localhost", 11211, {no_block=true, use_binary=true}, nil)
inst:add_server({"127.0.0.1", 11211})
print('>>\n>>')
print(' copyright = ' .. mem._COPYRIGHT)
print(' description = ' .. mem._DESCRIPTION)
print(' version = ' .. mem._VERSION)
print(' libmemcached version = ' .. mem._LIBVERSION)
print('>>\n>>')
print(inst:set_behavior({use_binary=true}))
local behaviors = inst:get_behavior({"use_udp", "no_block", "use_binary"})
simple_table_dump(behaviors, " :: behaviors :: ")
print(inst:set("foo", "xxxxyyyzzz zzzz www"))
print(inst:set({mee=11, moo="okey dokey"}))
local rtn = inst:get({"moo", "foo"})
print(rtn)
if type(rtn)=="table" then
simple_table_dump(rtn)
else
print(rtn)
end
local ax, bx = inst:get("mee")
print(ax)
print(bx)
inst = nil
collectgarbage()
print('>>\n>>')
print('this is the end, my only friend, the end ...')