Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Documentation for this module may be created at Module:Tr/loaddata/doc

-- Note: 
-- It seems that objects/lists stored via luacache have a limit on the number of entities,  which is about 8k.
-- Any object/list which has more then 8k entities or having such a large sub-object/sub-list will be truncated.
-- Therefore, we encode the data into a string to get around this problem.

local cache = mw.ext.LuaCache

return {
	
	load = function(lang)
		local status, result = pcall(function ()
			return mw.text.jsonDecode(cache.get('tr__database-'..lang))
		end)
		if status then
			return result
		else
			-- fallback
			local info = require('Module:Tr/db-'..lang) -- return table of mw.loadData() has a metatable, can not be used for cache.set and mw.loadData.
			
			-- add on wiki language list
			info.onWikiLangList = { ['ko'] = true }
			
			-- cache it. 
			-- This cache can be purged by:
			-- * purge Module:tr/db-<lang> or Module:tr/db-<lang>/doc page
			-- * lua code: require('Module:Tr/loaddata').purge(<lang>)
			-- * template code: {{#invoke:tr|purge|lang=<lang>}}
			cache.set( 'tr__database-'..lang, mw.text.jsonEncode(info))
			return info
		end
	end,
	
	purge = function(lang)
		cache.delete( 'tr__database-'..lang)
	end
}