jenkins-bot has submitted this change and it was merged.
Change subject: Made RepoGroup use ProcessCacheLRU
......................................................................
Made RepoGroup use ProcessCacheLRU
Change-Id: I322a6cf15566bde4fc5ee5bfa1be5fdc680cd763
---
M includes/cache/MapCacheLRU.php
M includes/filerepo/RepoGroup.php
2 files changed, 8 insertions(+), 39 deletions(-)
Approvals:
BryanDavis: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/cache/MapCacheLRU.php b/includes/cache/MapCacheLRU.php
index 3539d8f..26d3ec4 100644
--- a/includes/cache/MapCacheLRU.php
+++ b/includes/cache/MapCacheLRU.php
@@ -28,6 +28,7 @@
*
* @see ProcessCacheLRU
* @ingroup Cache
+ * @since 1.23
*/
class MapCacheLRU {
/** @var Array */
diff --git a/includes/filerepo/RepoGroup.php b/includes/filerepo/RepoGroup.php
index 1a7ae34..039f435 100644
--- a/includes/filerepo/RepoGroup.php
+++ b/includes/filerepo/RepoGroup.php
@@ -38,7 +38,7 @@
protected $localInfo;
protected $foreignInfo;
- /** @var array */
+ /** @var ProcessCacheLRU */
protected $cache;
/** @var RepoGroup */
@@ -94,7 +94,7 @@
function __construct( $localInfo, $foreignInfo ) {
$this->localInfo = $localInfo;
$this->foreignInfo = $foreignInfo;
- $this->cache = array();
+ $this->cache = new ProcessCacheLRU( self::MAX_CACHE_SIZE );
}
/**
@@ -136,13 +136,8 @@
) {
$time = isset( $options['time'] ) ? $options['time'] :
'';
$dbkey = $title->getDBkey();
- if ( isset( $this->cache[$dbkey][$time] ) ) {
- wfDebug( __METHOD__ . ": got File:$dbkey from
process cache\n" );
- # Move it to the end of the list so that we can
delete the LRU entry later
- $this->pingCache( $dbkey );
-
- # Return the entry
- return $this->cache[$dbkey][$time];
+ if ( $this->cache->has( $dbkey, $time, 60 ) ) {
+ return $this->cache->get( $dbkey, $time );
}
$useCache = true;
} else {
@@ -165,8 +160,7 @@
$image = $image ? $image : false; // type sanity
# Cache file existence or non-existence
if ( $useCache && ( !$image || $image->isCacheable() ) ) {
- $this->trimCache();
- $this->cache[$dbkey][$time] = $image;
+ $this->cache->set( $dbkey, $time, $image );
}
return $image;
@@ -435,40 +429,14 @@
}
/**
- * Move a cache entry to the top (such as when accessed)
- */
- protected function pingCache( $key ) {
- if ( isset( $this->cache[$key] ) ) {
- $tmp = $this->cache[$key];
- unset( $this->cache[$key] );
- $this->cache[$key] = $tmp;
- }
- }
-
- /**
- * Limit cache memory
- */
- protected function trimCache() {
- while ( count( $this->cache ) >= self::MAX_CACHE_SIZE ) {
- reset( $this->cache );
- $key = key( $this->cache );
- wfDebug( __METHOD__ . ": evicting $key\n" );
- unset( $this->cache[$key] );
- }
- }
-
- /**
* Clear RepoGroup process cache used for finding a file
* @param $title Title|null Title of the file or null to clear all files
*/
public function clearCache( Title $title = null ) {
if ( $title == null ) {
- $this->cache = array();
+ $this->cache->clear();
} else {
- $dbKey = $title->getDBkey();
- if ( isset( $this->cache[$dbKey] ) ) {
- unset( $this->cache[$dbKey] );
- }
+ $this->cache->clear( $title->getDBkey() );
}
}
}
--
To view, visit https://gerrit.wikimedia.org/r/98899
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I322a6cf15566bde4fc5ee5bfa1be5fdc680cd763
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Brian Wolff <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: IAlex <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits