Add the hostname cache prefix

This commit is contained in:
Mark J Crane
2025-10-20 14:29:28 -06:00
parent 9ba170b21c
commit 090d4580d6
5 changed files with 29 additions and 11 deletions

View File

@@ -44,6 +44,9 @@
--prepare the api object
api = freeswitch.API();
--get the hostname
local hostname = api:execute("hostname", "");
--define the functions
require "resources.functions.trim";
require "resources.functions.explode";
@@ -355,5 +358,5 @@
end
--clear the cache
if (feature_enabled ~= nil) then
cache.del("directory:"..user.."@"..host)
cache.del(hostname.."directory:"..user.."@"..host)
end

View File

@@ -34,6 +34,9 @@
--create the api object
api = freeswitch.API();
--get the hostname
local hostname = api:execute("hostname", "");
--includes
require "resources.functions.config";
require "resources.functions.channel_utils";
@@ -305,9 +308,9 @@
--clear the cache
if extension and #extension > 0 and cache.support() then
cache.del("directory:"..extension.."@"..domain_name);
cache.del(hostname..":directory:"..extension.."@"..domain_name);
if #number_alias > 0 then
cache.del("directory:"..number_alias.."@"..domain_name);
cache.del(hostname.."directory:"..number_alias.."@"..domain_name);
end
end

View File

@@ -25,8 +25,13 @@
--set default variables
max_tries = "3";
digit_timeout = "5000";
--create the api object
api = freeswitch.API();
--get the hostname
local hostname = api:execute("hostname", "");
--set the debug level
debug["sql"] = false;
debug["var"] = false;
@@ -230,17 +235,17 @@ if ( session:ready() ) then
--clear the cache
if (user_name ~= nil and context ~= nil) then
if (cache.support()) then
cache.del("directory:"..user_name.."@"..context);
cache.del(hostname..":directory:"..user_name.."@"..context);
if #number_alias > 0 then
cache.del("directory:"..number_alias.."@"..domain_name);
cache.del(hostname..":directory:"..number_alias.."@"..domain_name);
end
end
end
if (db_extension ~= nil and context ~= nil) then
if (cache.support()) then
cache.del("directory:"..db_extension.."@"..context);
cache.del(hostname..":directory:"..db_extension.."@"..context);
if #number_alias > 0 then
cache.del("directory:"..number_alias.."@"..domain_name);
cache.del(hostname..":directory:"..number_alias.."@"..domain_name);
end
end
end

View File

@@ -37,6 +37,9 @@
--create the api object
api = freeswitch.API();
--get the hostname
local hostname = api:execute("hostname", "");
--include config.lua
require "resources.functions.config";
@@ -262,9 +265,9 @@
--clear the cache
if extension and #extension > 0 and cache.support() then
cache.del("directory:"..extension.."@"..context);
cache.del(hostname..":directory:"..extension.."@"..context);
if #number_alias > 0 then
cache.del("directory:"..number_alias.."@"..context);
cache.del(hostname..":directory:"..number_alias.."@"..context);
end
end

View File

@@ -28,6 +28,10 @@
--create the api object
api = freeswitch.API();
--get the hostname
local hostname = api:execute("hostname", "");
--include and initialize additional objects
require "resources.functions.channel_utils";
local log = require "resources.functions.log".follow_me
local cache = require "resources.functions.cache"
@@ -133,9 +137,9 @@
--clear the cache
if (extension ~= nil) and cache.support() then
cache.del("directory:"..extension.."@"..domain_name);
cache.del(hostname..":directory:"..extension.."@"..domain_name);
if #number_alias > 0 then
cache.del("directory:"..number_alias.."@"..domain_name);
cache.del(hostname..":directory:"..number_alias.."@"..domain_name);
end
end