All pastes #57479 Raw Edit

Mine

public lua v1 · immutable
#57479 ·published 2006-05-21 05:58 UTC
rendered paste body
local 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,}