# HG changeset patch # User Matthew Wild # Date 1280661451 -3600 # Node ID 578214a34ded7c2cc74f36683bdf11fc204ca593 # Parent db66a09dc0b63971232528fc1de4860fafb101d1 Implement initial expiry support diff -r db66a09dc0b6 -r 578214a34ded util/memcache.lua --- a/util/memcache.lua Sun Aug 01 12:17:12 2010 +0100 +++ b/util/memcache.lua Sun Aug 01 12:17:31 2010 +0100 @@ -13,15 +13,22 @@ local _deleted = {}; function cache:set(key, flags, expires, data) - if expires ~= 0 then - return false, "Expiry is not currently implemented"; + _flags[key] = flags; + if expires > 0 then + if expires <= max_expires_seconds then + expires = now() + expires; + end + _expiry[key] = expires; end - _flags[key] = flags; _data[key] = data; return true; end function cache:get(key) + local expires = _expiry[key]; + if expires and expires > now() then + self:delete(key); + end return _flags[key], _data[key]; end