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

Change subject: Tweaked "latest" handling of filebackend stat entries
......................................................................


Tweaked "latest" handling of filebackend stat entries

* Let "latest" stat entries override non "latest" so
  that future getFileStat() calls with the "latest" flag
  can actually have a cache hit.

Change-Id: I1e9391039537d608b89773b4d51575e3b364a751
---
M includes/filebackend/FileBackendStore.php
1 file changed, 16 insertions(+), 1 deletion(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/filebackend/FileBackendStore.php 
b/includes/filebackend/FileBackendStore.php
index 2d8214e..2fd1bf6 100644
--- a/includes/filebackend/FileBackendStore.php
+++ b/includes/filebackend/FileBackendStore.php
@@ -1666,7 +1666,22 @@
                }
                $age = time() - wfTimestamp( TS_UNIX, $val['mtime'] );
                $ttl = min( 7 * 86400, max( 300, floor( .1 * $age ) ) );
-               $this->memCache->add( $this->fileCacheKey( $path ), $val, $ttl 
);
+               $key = $this->fileCacheKey( $path );
+               // Set the cache unless it is currently salted with the value 
"PURGED".
+               // Using add() handles this except it also is a no-op in that 
case where
+               // the current value is not "latest" but $val is, so use CAS in 
that case.
+               if ( !$this->memCache->add( $key, $val, $ttl ) && !empty( 
$val['latest'] ) ) {
+                       $this->memCache->merge(
+                               $key,
+                               function( BagOStuff $cache, $key, $cValue ) use 
( $val ) {
+                                       return ( is_array( $cValue ) && empty( 
$cValue['latest'] ) )
+                                               ? $val // update the stat cache 
with the lastest info
+                                               : false; // do nothing (cache 
is salted or some error happened)
+                               },
+                               $ttl,
+                               1
+                       );
+               }
        }
 
        /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1e9391039537d608b89773b4d51575e3b364a751
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to