From 03b281d55bbafd5746db580676beed9c262261b6 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 3 Nov 2015 06:36:06 +0000 Subject: [PATCH] objectcache: Add TTL_INDEFINITE to IExpiringStore Especially useful when interacting with getWithSetCallback of HashBagOStuff where a $exptime is required before the callback. In set() it is typically left out and thus not as counter-intuitive. Change-Id: Ic2f7adda3c00cefe701d77bea91a7e8e77ef1439 --- includes/libs/objectcache/HashBagOStuff.php | 2 +- includes/libs/objectcache/IExpiringStore.php | 2 ++ includes/libs/objectcache/WANObjectCache.php | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/libs/objectcache/HashBagOStuff.php b/includes/libs/objectcache/HashBagOStuff.php index bdcf18017f..432d040cd6 100644 --- a/includes/libs/objectcache/HashBagOStuff.php +++ b/includes/libs/objectcache/HashBagOStuff.php @@ -50,7 +50,7 @@ class HashBagOStuff extends BagOStuff { protected function expire( $key ) { $et = $this->bag[$key][self::KEY_EXP]; - if ( $et == 0 || $et > time() ) { + if ( $et == self::TTL_INDEFINITE || $et > time() ) { return false; } diff --git a/includes/libs/objectcache/IExpiringStore.php b/includes/libs/objectcache/IExpiringStore.php index b5ad702a53..fa465c7d35 100644 --- a/includes/libs/objectcache/IExpiringStore.php +++ b/includes/libs/objectcache/IExpiringStore.php @@ -37,4 +37,6 @@ interface IExpiringStore { const TTL_WEEK = 604800; // 7 * 24 * 3600 const TTL_MONTH = 2592000; // 30 * 24 * 3600 const TTL_YEAR = 31536000; // 365 * 24 * 3600 + + const TTL_INDEFINITE = 0; } diff --git a/includes/libs/objectcache/WANObjectCache.php b/includes/libs/objectcache/WANObjectCache.php index c04d4b6be4..7e3fa4fd47 100644 --- a/includes/libs/objectcache/WANObjectCache.php +++ b/includes/libs/objectcache/WANObjectCache.php @@ -95,8 +95,6 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { /** Default time-since-expiry on a miss that makes a key "hot" */ const LOCK_TSE = 1; - /** Idiom for set()/getWithSetCallback() TTL being "forever" */ - const TTL_INDEFINITE = 0; /** Idiom for getWithSetCallback() callbacks to avoid calling set() */ const TTL_UNCACHEABLE = -1; /** Idiom for getWithSetCallback() callbacks to 'lockTSE' logic */ -- 2.20.1