Krinkle has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/250643

Change subject: objectcache: Add TTL_INDEFINITE to IExpiringStore
......................................................................

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
---
M includes/libs/objectcache/HashBagOStuff.php
M includes/libs/objectcache/IExpiringStore.php
M includes/libs/objectcache/WANObjectCache.php
3 files changed, 3 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/43/250643/1

diff --git a/includes/libs/objectcache/HashBagOStuff.php 
b/includes/libs/objectcache/HashBagOStuff.php
index bdcf180..432d040 100644
--- a/includes/libs/objectcache/HashBagOStuff.php
+++ b/includes/libs/objectcache/HashBagOStuff.php
@@ -50,7 +50,7 @@
 
        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 b5ad702..fa465c7 100644
--- a/includes/libs/objectcache/IExpiringStore.php
+++ b/includes/libs/objectcache/IExpiringStore.php
@@ -37,4 +37,6 @@
        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 c04d4b6..7e3fa4f 100644
--- a/includes/libs/objectcache/WANObjectCache.php
+++ b/includes/libs/objectcache/WANObjectCache.php
@@ -95,8 +95,6 @@
        /** 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 */

-- 
To view, visit https://gerrit.wikimedia.org/r/250643
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic2f7adda3c00cefe701d77bea91a7e8e77ef1439
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to