Improve the variable naming convention used for memcache. Add memcache support for call groups.
This commit is contained in:
parent
2a7274d50a
commit
2c4e86821e
|
|
@ -134,7 +134,7 @@
|
|||
|
||||
--get the cache
|
||||
if (trim(api:execute("module_exists", "mod_memcache")) == "true") then
|
||||
XML_STRING = trim(api:execute("memcache", "get sofia.conf"));
|
||||
XML_STRING = trim(api:execute("memcache", "get configuration:sofia.conf"));
|
||||
else
|
||||
XML_STRING = "-ERR NOT FOUND";
|
||||
end
|
||||
|
|
@ -348,7 +348,7 @@
|
|||
end
|
||||
|
||||
--set the cache
|
||||
result = trim(api:execute("memcache", "set sofia.conf '"..XML_STRING:gsub("'", "'").."' "..expire["sofia.conf"]));
|
||||
result = trim(api:execute("memcache", "set configuration:sofia.conf '"..XML_STRING:gsub("'", "'").."' "..expire["sofia.conf"]));
|
||||
|
||||
--send the xml to the console
|
||||
if (debug["xml_string"]) then
|
||||
|
|
@ -359,7 +359,7 @@
|
|||
|
||||
--send to the console
|
||||
if (debug["cache"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] sofia.conf source: database\n");
|
||||
freeswitch.consoleLog("notice", "[xml_handler] configuration:sofia.conf source: database\n");
|
||||
end
|
||||
else
|
||||
--replace the ' back to a single quote
|
||||
|
|
@ -367,7 +367,7 @@
|
|||
|
||||
--send to the console
|
||||
if (debug["cache"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] sofia.conf source: memcache\n");
|
||||
freeswitch.consoleLog("notice", "[xml_handler] configuration:sofia.conf source: memcache\n");
|
||||
end
|
||||
end --if XML_STRING
|
||||
end --sofia.conf
|
||||
|
|
@ -479,6 +479,13 @@
|
|||
--handles action
|
||||
--group_call
|
||||
|
||||
--attempt to use the cache
|
||||
if (trim(api:execute("module_exists", "mod_memcache")) == "true") then
|
||||
XML_STRING = trim(api:execute("memcache", "get directory:groups"));
|
||||
else
|
||||
XML_STRING = "-ERR NOT FOUND";
|
||||
end
|
||||
if (XML_STRING == "-ERR NOT FOUND") then
|
||||
--build the call group array
|
||||
sql = [[
|
||||
select * from v_extensions
|
||||
|
|
@ -544,23 +551,41 @@
|
|||
table.insert(xml, [[</document>]]);
|
||||
XML_STRING = table.concat(xml, "\n");
|
||||
|
||||
--set the cache
|
||||
result = trim(api:execute("memcache", "set directory:groups '"..XML_STRING:gsub("'", "'").."' "..expire["directory"]));
|
||||
|
||||
--send to the console
|
||||
if (debug["cache"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] directory:groups source: database\n");
|
||||
end
|
||||
|
||||
else
|
||||
--replace the ' back to a single quote
|
||||
XML_STRING = XML_STRING:gsub("'", "'");
|
||||
|
||||
--send to the console
|
||||
if (debug["cache"]) then
|
||||
if (XML_STRING) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] directory:groups source: memcache\n");
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--send the xml to the console
|
||||
if (debug["xml_string"]) then
|
||||
freeswitch.consoleLog("notice", "[directory] XML_STRING: \n" .. XML_STRING .. "\n");
|
||||
freeswitch.consoleLog("notice", "[directory] Groups XML_STRING: \n" .. XML_STRING .. "\n");
|
||||
end
|
||||
else
|
||||
--handle action
|
||||
--all directory actions: sip_auth, user_call
|
||||
--all other directory actions: sip_auth, user_call
|
||||
--except for the action: group_call
|
||||
|
||||
--get the cache
|
||||
if (trim(api:execute("module_exists", "mod_memcache")) == "true") then
|
||||
XML_STRING = trim(api:execute("memcache", "get " .. user .. "@" .. domain_name));
|
||||
XML_STRING = trim(api:execute("memcache", "get directory:" .. user .. "@" .. domain_name));
|
||||
if (XML_STRING == "-ERR NOT FOUND") then
|
||||
continue = true;
|
||||
else
|
||||
--replace the ' back to a single quote
|
||||
XML_STRING = XML_STRING:gsub("'", "'");
|
||||
continue = false;
|
||||
end
|
||||
else
|
||||
|
|
@ -795,7 +820,7 @@
|
|||
XML_STRING = table.concat(xml, "\n");
|
||||
|
||||
--set the cache
|
||||
result = trim(api:execute("memcache", "set " .. user .. "@" .. domain_name .. " '"..XML_STRING:gsub("'", "'").."' "..expire["directory"]));
|
||||
result = trim(api:execute("memcache", "set directory:" .. user .. "@" .. domain_name .. " '"..XML_STRING:gsub("'", "'").."' "..expire["directory"]));
|
||||
|
||||
--send the xml to the console
|
||||
if (debug["xml_string"]) then
|
||||
|
|
@ -809,6 +834,9 @@
|
|||
freeswitch.consoleLog("notice", "[xml_handler] directory:" .. user .. "@" .. domain_name .. " source: database\n");
|
||||
end
|
||||
else
|
||||
--replace the ' back to a single quote
|
||||
XML_STRING = XML_STRING:gsub("'", "'");
|
||||
|
||||
--send to the console
|
||||
if (debug["cache"]) then
|
||||
if (XML_STRING) then
|
||||
|
|
@ -832,11 +860,10 @@
|
|||
|
||||
--get the cache
|
||||
if (trim(api:execute("module_exists", "mod_memcache")) == "true") then
|
||||
XML_STRING = trim(api:execute("memcache", "get " .. call_context));
|
||||
XML_STRING = trim(api:execute("memcache", "get dialplan:" .. call_context));
|
||||
else
|
||||
XML_STRING = "-ERR NOT FOUND";
|
||||
end
|
||||
|
||||
if (XML_STRING == "-ERR NOT FOUND") then
|
||||
--set the xml array and then concatenate the array to a string
|
||||
local xml = {}
|
||||
|
|
@ -1045,7 +1072,7 @@
|
|||
|
||||
--set the cache
|
||||
tmp = XML_STRING:gsub("\\", "\\\\");
|
||||
result = trim(api:execute("memcache", "set " .. call_context .. " '"..tmp:gsub("'", "'").."' "..expire["dialplan"]));
|
||||
result = trim(api:execute("memcache", "set dialplan:" .. call_context .. " '"..tmp:gsub("'", "'").."' "..expire["dialplan"]));
|
||||
|
||||
--send the xml to the console
|
||||
if (debug["xml_string"]) then
|
||||
|
|
|
|||
Loading…
Reference in New Issue