Sun, 01 Aug 2010 12:17:12 +0100
Add 'delete' command
local now = os.time; module("memcache", package.seeall); local max_expires_seconds = 60*60*24*30; function new() local cache = {}; local _data = {}; local _flags = {}; local _expiry = {}; local _deleted = {}; function cache:set(key, flags, expires, data) if expires ~= 0 then return false, "Expiry is not currently implemented"; end _flags[key] = flags; _data[key] = data; return true; end function cache:get(key) return _flags[key], _data[key]; end function cache:delete(key, time) local existed = _data[key]; _flags[key], _data[key], _expires[key] = nil, nil, nil; if existed and time then if time <= max_expires_seconds then time = now() + time; end _deleted[key] = time; end return true, existed; end return cache; end return _M;