From 8afafe6beb4461cc60608138f5d858a453fbc58e Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Tue, 6 Oct 2015 16:01:24 +0400 Subject: [PATCH 1/2] Add. `cache` class emit MEMCACHE events. --- .../install/scripts/resources/functions/cache.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/resources/install/scripts/resources/functions/cache.lua b/resources/install/scripts/resources/functions/cache.lua index 974e327dd9..5969bf20ef 100644 --- a/resources/install/scripts/resources/functions/cache.lua +++ b/resources/install/scripts/resources/functions/cache.lua @@ -10,6 +10,16 @@ require "resources.functions.trim"; local api = api or freeswitch.API(); +local function send_event(action, key) + -- we need send event only if we use load_balance=true + -- but since this option set only in directory we can not + -- check it here. + local event = freeswitch.Event("MEMCACHE", action); + event:addHeader("API-Command", "memcache"); + event:addHeader("API-Command-Argument", action .. " " .. key); + event:fire() +end + local Cache = {} local function check_error(result) @@ -57,6 +67,7 @@ function Cache.set(key, value, expire) end function Cache.del(key) + send_event('delete', key) local result, err = check_error(api:execute("memcache", "delete " .. key)) if not result then if err == 'NOT FOUND' then From 7187766c1171ea4a9a15cebdd7d16112395dbc0f Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Mon, 26 Oct 2015 12:27:14 +0300 Subject: [PATCH 2/2] Update comment. --- resources/install/scripts/resources/functions/cache.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/resources/install/scripts/resources/functions/cache.lua b/resources/install/scripts/resources/functions/cache.lua index 5969bf20ef..06548af1cd 100644 --- a/resources/install/scripts/resources/functions/cache.lua +++ b/resources/install/scripts/resources/functions/cache.lua @@ -11,9 +11,6 @@ require "resources.functions.trim"; local api = api or freeswitch.API(); local function send_event(action, key) - -- we need send event only if we use load_balance=true - -- but since this option set only in directory we can not - -- check it here. local event = freeswitch.Event("MEMCACHE", action); event:addHeader("API-Command", "memcache"); event:addHeader("API-Command-Argument", action .. " " .. key);