Skip to content

Commit 1a36a0e

Browse files
committed
Merge branch 'develop' of github.com:pintsized/lua-resty-redis-connector into develop
2 parents f00f4e6 + bbdc792 commit 1a36a0e

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/resty/redis/connector.lua

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,27 @@ local function tbl_copy(orig)
5050
end
5151

5252

53+
-- Returns a new table, recursively copied from the one given, retaining
54+
-- metatable assignment.
55+
--
56+
-- @param table table to be copied
57+
-- @return table
58+
local function tbl_copy(orig)
59+
local orig_type = type(orig)
60+
local copy
61+
if orig_type == "table" then
62+
copy = {}
63+
for orig_key, orig_value in next, orig, nil do
64+
copy[tbl_copy(orig_key)] = tbl_copy(orig_value)
65+
end
66+
setmetatable(copy, tbl_copy(getmetatable(orig)))
67+
else -- number, string, boolean, etc
68+
copy = orig
69+
end
70+
return copy
71+
end
72+
73+
5374
-- Returns a new table, recursively copied from the combination of the given
5475
-- table `t1`, with any missing fields copied from `defaults`.
5576
--
@@ -89,7 +110,6 @@ local DEFAULTS = setmetatable({
89110

90111
keepalive_timeout = 60000,
91112
keepalive_poolsize = 30,
92-
93113
host = "127.0.0.1",
94114
port = 6379,
95115
path = "", -- /tmp/redis.sock

t/sentinel.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ location /t {
141141
assert(slaveports["6378"] == false and slaveports["6380"] == true,
142142
"only 6380 should be found")
143143

144+
r:slaveof("127.0.0.1", 6379)
144145
sentinel:close()
145146
}
146147
}

0 commit comments

Comments
 (0)