util.memcache: Fix backwards expiry logic and nil global access

Sun, 01 Aug 2010 12:20:27 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sun, 01 Aug 2010 12:20:27 +0100
changeset 15
87ef478bf7fc
parent 14
578214a34ded
child 16
906615e293de

util.memcache: Fix backwards expiry logic and nil global access

util/memcache.lua file | annotate | diff | comparison | revisions
--- a/util/memcache.lua	Sun Aug 01 12:17:31 2010 +0100
+++ b/util/memcache.lua	Sun Aug 01 12:20:27 2010 +0100
@@ -26,7 +26,7 @@
 	
 	function cache:get(key)
 		local expires = _expiry[key];
-		if expires and expires > now() then
+		if expires and expires < now() then
 			self:delete(key);
 		end
 		return _flags[key], _data[key];
@@ -34,7 +34,7 @@
 	
 	function cache:delete(key, time)
 		local existed = _data[key];
-		_flags[key], _data[key], _expires[key] = nil, nil, nil;
+		_flags[key], _data[key], _expiry[key] = nil, nil, nil;
 		if existed and time then
 			if time <= max_expires_seconds then
 				time = now() + time;

mercurial