Skip to content

Commit

Permalink
add bulkremove for consumer_table_pops.lua (#306)
Browse files Browse the repository at this point in the history
- 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]
  • Loading branch information
dzhangalibaba authored and lguohan committed Sep 19, 2019
1 parent 6b805d3 commit 379ac73
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions common/consumer_table_pops.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ for i = n, 1, -3 do
end
table.insert(rets, ret)

if op == 'bulkset' or op == 'bulkcreate' then
if op == 'bulkset' or op == 'bulkcreate' or op == 'bulkremove' then

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

if op == 'bulkremove' then
redis.call('DEL', keyname)
else
-- value can be multiple a=v|a=v|... we need to split using gmatch
local vars = ret[st+1]
for value in string.gmatch(vars,'([^|]+)') do
local attr = value:sub(1, string.find(value, '=') - 1)
local val = value.sub(value, string.find(value, '=') + 1)
redis.call('HSET', keyname, attr, val)
local vars = ret[st+1]
for value in string.gmatch(vars,'([^|]+)') do
local attr = value:sub(1, string.find(value, '=') - 1)
local val = value.sub(value, string.find(value, '=') + 1)
redis.call('HSET', keyname, attr, val)
end
end

st = st + 2
Expand Down

0 comments on commit 379ac73

Please sign in to comment.