objectcache: Add TTL_INDEFINITE to IExpiringStore
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 3 Nov 2015 06:36:06 +0000 (06:36 +0000)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 3 Nov 2015 06:36:06 +0000 (06:36 +0000)
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
includes/libs/objectcache/IExpiringStore.php
includes/libs/objectcache/WANObjectCache.php

index bdcf180..432d040 100644 (file)
@@ -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;
                }
 
index b5ad702..fa465c7 100644 (file)
@@ -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;
 }
index c04d4b6..7e3fa4f 100644 (file)
@@ -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 */