Update cache.lua

Make the cache.lua more robust in case of missing key or value.
This commit is contained in:
FusionPBX
2018-01-19 18:39:05 -07:00
committed by GitHub
parent a52c4ab0c8
commit a11fb1a4ef

View File

@@ -80,17 +80,32 @@ end
-- convert cache key to memcache key
local function key2key(key)
return (string.gsub(key, "\\", "\\\\"))
if (key) then
key = string.gsub(key, "\\", "\\\\");
else
key = '';
end
return key;
end
-- encode value to be able store it in memcache
local function memcache_encode(value)
return (string.gsub(value, "'", "'"):gsub("\\", "\\\\"))
if (value) then
value = string.gsub(value, "'", "'"):gsub("\\", "\\\\");
else
value = '';
end
return value;
end
-- decode value retrived from memcache
local function memcache_decode(value)
return (string.gsub(value, "'", "'"))
if (value) then
value = string.gsub(value, "'", "'");
else
value = '';
end
return value;
end
function Cache.support()