Merge pull request #1186 from moteus/cache_emit_event
Add. `cache` class emit MEMCACHE events.
This commit is contained in:
@@ -10,6 +10,13 @@ require "resources.functions.trim";
|
|||||||
|
|
||||||
local api = api or freeswitch.API();
|
local api = api or freeswitch.API();
|
||||||
|
|
||||||
|
local function send_event(action, key)
|
||||||
|
local event = freeswitch.Event("MEMCACHE", action);
|
||||||
|
event:addHeader("API-Command", "memcache");
|
||||||
|
event:addHeader("API-Command-Argument", action .. " " .. key);
|
||||||
|
event:fire()
|
||||||
|
end
|
||||||
|
|
||||||
local Cache = {}
|
local Cache = {}
|
||||||
|
|
||||||
local function check_error(result)
|
local function check_error(result)
|
||||||
@@ -57,6 +64,7 @@ function Cache.set(key, value, expire)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Cache.del(key)
|
function Cache.del(key)
|
||||||
|
send_event('delete', key)
|
||||||
local result, err = check_error(api:execute("memcache", "delete " .. key))
|
local result, err = check_error(api:execute("memcache", "delete " .. key))
|
||||||
if not result then
|
if not result then
|
||||||
if err == 'NOT FOUND' then
|
if err == 'NOT FOUND' then
|
||||||
|
|||||||
Reference in New Issue
Block a user