Module:Cache

local trim = mw.text.trim local cache = require 'mw.ext.LuaCache'

local args_table -- cache -- helper function local getArg = function(key) local value = trim(args_table[key] or '') return (value ~= '') and value or nil end

-- A simple wrap for LuaCache

return { -- get -- return cached value or nil get = function(frame) args_table = frame.args local result = cache.get(getArg(1) or getArg('key')) if result then return tostring(result) end end,

-- set -- return 'true' or '' if $return or $4 = true set = function(frame) args_table = frame.args local result = cache.set(getArg(1) or getArg('key'), getArg(2) or getArg('value'), getArg(3) or getArg('exptime')) if getArg('return') or getArg(4) then return result or '' end end,

-- delete -- eturn 'true' or '' if $return or $2 = true delete = function(frame) args_table = frame.args local result = cache.delete(getArg(1) or getArg('key')) if getArg('return') or getArg(2) then return result or '' end end,

}