local n={}n.__index=n function n.new(I)local w=setmetatable({},n)assert(typeof(I)=="\110\117\109\098\101\114","\067\097\099\104\101 \101\120\112\101\099\116\105\110\103 \110\117\109\098\101\114\044 \103\111\116 "..typeof(I))w._cache=table.create(I)w._size=I return w end function n.Get(I,n)assert(typeof(n)=="\115\116\114\105\110\103")for I,w in ipairs(I._cache)do if w.key==n then return w.value,I end end return nil end function n.Set(w,n,I)assert(typeof(n)=="\115\116\114\105\110\103")assert(I)local E,J=w:Get(n)if J then local n=table.remove(w._cache,J)table.insert(w._cache,n)else local E={key=n;value=I}if#w._cache>w._size then table.remove(w._cache,1)table.insert(w._cache,w._size,E)else table.insert(w._cache,E)end end end function n.Destroy(n)table.clear(n._cache)n._cache=nil n._size=nil setmetatable(n,nil)end return n
-- Class
-- 0_1195
-- January 10, 2021

--[[



]]

local Class = {}
Class.__index = Class


function Class.new(size)
	local self = setmetatable({}, Class)
	
	assert(typeof(size) == "number", "Cache expecting number, got " .. typeof(size))
	
	self._cache = table.create(size)
	self._size = size
	
	return self
end


function Class:Get(key)
	assert(typeof(key) == "string")
	
	for i, v in ipairs(self._cache) do
		if v.key == key then
			return v.value, i
		end
	end
	
	return nil
end


function Class:Set(key, value)
	assert(typeof(key) == "string")
	assert(value)
	
	local cachedValue, index = self:Get(key)
	if index then
		local data = table.remove(self._cache, index)
		table.insert(self._cache, data)
	else
		local data = {
			key = key,
			value = value,
		}
		if #self._cache > self._size then
			table.remove(self._cache, 1)
			table.insert(self._cache, self._size, data)
		else
			table.insert(self._cache, data)
		end
	end
end


function Class:Destroy()
	table.clear(self._cache)
	self._cache = nil
	self._size = nil
	setmetatable(self, nil)
end


return Class