Fix expiration by age
Fix expiration by age

--- a/include/cache/memcache_cache_handler.php
+++ b/include/cache/memcache_cache_handler.php
@@ -39,7 +39,7 @@
 
 			if (!isset($exp_time))
 				$exp_time = 0;
-			$map[$fullKey] = $exp_time;
+			$map[$fullKey] = time();
 
 			$memObj->Set($namespace . $fullKey, $cache_content, $exp_time);
 			$memObj->Set($namespace . MEMCACHE_OBJECT_MAP, $map);
@@ -63,6 +63,7 @@
 
 			$map = $memObj->Get($namespace . MEMCACHE_OBJECT_MAP);
 			if (isset($map) && is_array($map)) {
+				$now = time();
 				/*
 				 * Search through our stored map of keys
 				 */
@@ -84,7 +85,7 @@
 					     * If we have an expiration time,
 					     * match any keys older than that
 					     */
-					    ((!isset($exp_time)) || ($age < $exp_time))
+					    ((!isset($exp_time)) || (($now - $age) > $exp_time))
 					) {
 						$memObj->Delete($namespace . $key);
 						unset($map[$key]);

comments