jenkins-bot has submitted this change and it was merged.

Change subject: Added WANObjectCache::TTL_UNCACHEABLE for uncacheable content
......................................................................


Added WANObjectCache::TTL_UNCACHEABLE for uncacheable content

Change-Id: If7b75654c91cc5762cb49d90f40e1b7ea518ebc8
---
M includes/libs/objectcache/WANObjectCache.php
1 file changed, 7 insertions(+), 3 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/libs/objectcache/WANObjectCache.php 
b/includes/libs/objectcache/WANObjectCache.php
index 0ca0f2e..8d202c7 100755
--- a/includes/libs/objectcache/WANObjectCache.php
+++ b/includes/libs/objectcache/WANObjectCache.php
@@ -76,6 +76,8 @@
 
        /** Idiom for set()/getWithSetCallback() TTL */
        const TTL_NONE = 0;
+       /** Idiom for getWithSetCallback() callbacks to avoid calling set() */
+       const TTL_UNCACHEABLE = -1;
 
        /** Cache format version number */
        const VERSION = 1;
@@ -365,7 +367,9 @@
         *
         * @param string $key Cache key
         * @param callable $callback Value generation function
-        * @param integer $ttl Seconds to live when the key is updated 
[0=forever]
+        * @param integer $ttl Seconds to live for key updates. Special values 
are:
+        *   - WANObjectCache::TTL_NONE        : cache forever
+        *   - WANObjectCache::TTL_UNCACHEABLE : do not cache at all
         * @param array $checkKeys List of "check" keys
         * @param array $opts Options map:
         *   - lowTTL  : consider pre-emptive updates when the current TTL (sec)
@@ -432,7 +436,7 @@
                $value = call_user_func_array( $callback, array( $cValue, &$ttl 
) );
                // When delete() is called, writes are write-holed by the 
tombstone,
                // so use a special stash key to pass the new value around 
threads.
-               if ( $value !== false && ( $isHot || $isTombstone ) ) {
+               if ( $value !== false && ( $isHot || $isTombstone ) && $ttl >= 
0 ) {
                        $this->cache->set( self::STASH_KEY_PREFIX . $key, 
$value, $tempTTL );
                }
 
@@ -440,7 +444,7 @@
                        $this->cache->unlock( $key );
                }
 
-               if ( $value !== false ) {
+               if ( $value !== false && $ttl >= 0 ) {
                        // Update the cache; this will fail if the key is 
tombstoned
                        $this->set( $key, $value, $ttl );
                }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If7b75654c91cc5762cb49d90f40e1b7ea518ebc8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to