Skip to content

Commit 379ac73

Browse files
dzhangalibabalguohan
authored andcommitted
add bulkremove for consumer_table_pops.lua (#306)
- consumer_table_pops.lua added bulkremove option which will DEL redis DB entries - this change is along with changes in sonic-sairedis , sonic-net/sonic-sairedis#516 Signed-off-by: Dong Zhang [email protected]
1 parent 6b805d3 commit 379ac73

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

common/consumer_table_pops.lua

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ for i = n, 1, -3 do
2323
end
2424
table.insert(rets, ret)
2525

26-
if op == 'bulkset' or op == 'bulkcreate' then
26+
if op == 'bulkset' or op == 'bulkcreate' or op == 'bulkremove' then
2727

2828
-- key is "OBJECT_TYPE:num", extract object type from key
2929
key = key:sub(1, string.find(key, ':') - 1)
@@ -35,12 +35,16 @@ for i = n, 1, -3 do
3535
-- keyname is ASIC_STATE : OBJECT_TYPE : OBJECT_ID
3636
local keyname = KEYS[2] .. ':' .. key .. ':' .. field
3737

38+
if op == 'bulkremove' then
39+
redis.call('DEL', keyname)
40+
else
3841
-- value can be multiple a=v|a=v|... we need to split using gmatch
39-
local vars = ret[st+1]
40-
for value in string.gmatch(vars,'([^|]+)') do
41-
local attr = value:sub(1, string.find(value, '=') - 1)
42-
local val = value.sub(value, string.find(value, '=') + 1)
43-
redis.call('HSET', keyname, attr, val)
42+
local vars = ret[st+1]
43+
for value in string.gmatch(vars,'([^|]+)') do
44+
local attr = value:sub(1, string.find(value, '=') - 1)
45+
local val = value.sub(value, string.find(value, '=') + 1)
46+
redis.call('HSET', keyname, attr, val)
47+
end
4448
end
4549

4650
st = st + 2

0 commit comments

Comments
 (0)