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