Mine
public lua v1 · immutablelocal registry = {}LimitedCache = { new = function(self,max,o) if(not max or type(max) ~= "number" or max <= 0 or math.mod(max,1) ~= 0) then error("You must provide a cache size in the form of a positive integer",2) end o = setmetatable(o or {},self) registry[o] = {max = max} return o end, __newindex = function(t,k,v) local mt = registry[t] if(table.getn(mt) == mt.max) then t[table.remove(mt,1)] = nil end table.insert(mt,k) rawset(t,k,v) end,}