TT#65050 Add additional functions to recentcall.lua

Added:
 * set_element_by_key
 * get_element_by_key

Change-Id: I50009ecbc51ecae08dd055d2a099b2cffca82c3c
changes/63/32463/4
Marco Capetta 6 years ago
parent 50b2460aa6
commit 8a69b179d8

@ -47,7 +47,8 @@ end
port = 6379,
db = "7"
},
expire = 7200
expire = 7200,
out_expire = 86400
},
central = {},
};
@ -97,6 +98,38 @@ end
return res
end
function NGCPRecentCalls:set_element_by_key(key, element, value)
if not self._test_connection(self.central) then
self.central = self._connect(self.config.central)
end
local res = self.central:hmset(key, element, value)
if res then
self.central:expire(key, self.config.out_expire)
end
sr.log("info", string.format("central:hset[%s]=>[%s] %s: %s expire: %d\n",
key, tostring(res),
element, tostring(value),
self.config.out_expire))
return res
end
function NGCPRecentCalls:get_element_by_key(key, element)
if not self._test_connection(self.central) then
self.central = self._connect(self.config.central)
end
local res = self.central:hgetall(key)
if res then
sr.log("info", string.format("central:hget[%s]=>[%s]\n",
key, tostring(res[element])))
return res[element]
end
return 0
end
-- class
return NGCPRecentCalls

Loading…
Cancel
Save