Module:UtilsCache

From Zelda Wiki, the Zelda encyclopedia
Jump to navigation Jump to search

A wrapper around mw.ext.LuaCache (Extension:LuaCache) that no-ops if the extension is disabled. This allows the wiki to continue functioning normally (albeit more slowly) if the extension is unavailable.


local p = {}

local LuaCache = mw.ext.LuaCache

function p.get(key)
	return LuaCache and LuaCache.get(key)
end

function p.set(key, value)
	if LuaCache then
		LuaCache.set(key, value)
	end
end

function p.setMulti(entries)
	if LuaCache then
		LuaCache.setMulti(entries)
	end
end

function p.delete(key)
	if LuaCache then
		LuaCache.delete(key)
	end
end

return p