@@ -48,7 +48,7 @@ class RedisDb(object):
48
48
lua_script_utilities = """
49
49
local get_index = function(key, start, delimiter)
50
50
-- Get index of the first delimiter of the key
51
- local index = string.find(key, delimiter, start)
51
+ local index = string.find(key, delimiter, start, true )
52
52
if index == nil then
53
53
return #key
54
54
end
@@ -93,6 +93,9 @@ class RedisDb(object):
93
93
94
94
if marker == "" then
95
95
marker = "-"
96
+ if prefix ~= "" then
97
+ marker = "[" .. prefix
98
+ end
96
99
else
97
100
marker = "[" .. marker
98
101
end
@@ -107,8 +110,11 @@ class RedisDb(object):
107
110
for i=1, #keys do
108
111
local elem = keys[i]
109
112
if recursive ~= '1' then
110
- elem = get_first_level(keys[i], prefix_len + 1,
113
+ elem = get_first_level(keys[i], prefix_len + 1,
111
114
delimiter)
115
+ -- if we found a prefix, skip remaining stuff ?
116
+ -- but we should check keys array instead
117
+ -- instead triggering a new zrangebylex
112
118
end
113
119
114
120
-- there is no `continue` instruction on Lua
@@ -126,9 +132,16 @@ class RedisDb(object):
126
132
end
127
133
end
128
134
135
+
129
136
if #keys <= 1 then
130
137
finish = true
131
138
else
139
+ if prefix ~= "" then
140
+ -- if key doesn't match prefix, stop looping
141
+ if string.find(keys[#keys], prefix, 1, true) == nil then
142
+ finish = true
143
+ end
144
+ end
132
145
marker = "[" .. keys[#keys]
133
146
end
134
147
end
@@ -548,7 +561,7 @@ def header_cb(header_dict):
548
561
# empty if key does not exist
549
562
for entry in key_list :
550
563
matches .append ((mode , entry ))
551
- LOG .debug ("SHARD: prefix %s / matches: %s " , prefix_key , matches )
564
+ LOG .debug ("SHARD: prefix %s / matches: %d " , prefix_key , len ( matches ) )
552
565
553
566
if parse_root :
554
567
matches .append ((CNT , "" ))
0 commit comments