From 2f23133bb669dc4c810bd5b1ed8d5d47ee995b66 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 11 Jul 2018 13:53:23 +0100 Subject: [PATCH] filerepo: switch callers from ProcessCacheLRU to MapCacheLRU Change-Id: I58706b5610e0113a0c8d86eed2662870198f9b46 --- includes/filerepo/FileBackendDBRepoWrapper.php | 12 ++++++------ includes/filerepo/RepoGroup.php | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/includes/filerepo/FileBackendDBRepoWrapper.php b/includes/filerepo/FileBackendDBRepoWrapper.php index dbb542172d..b4454878cd 100644 --- a/includes/filerepo/FileBackendDBRepoWrapper.php +++ b/includes/filerepo/FileBackendDBRepoWrapper.php @@ -45,7 +45,7 @@ class FileBackendDBRepoWrapper extends FileBackend { protected $repoName; /** @var Closure */ protected $dbHandleFunc; - /** @var ProcessCacheLRU */ + /** @var MapCacheLRU */ protected $resolvedPathCache; /** @var DBConnRef[] */ protected $dbs; @@ -59,7 +59,7 @@ class FileBackendDBRepoWrapper extends FileBackend { $this->backend = $config['backend']; $this->repoName = $config['repoName']; $this->dbHandleFunc = $config['dbHandleFactory']; - $this->resolvedPathCache = new ProcessCacheLRU( 100 ); + $this->resolvedPathCache = new MapCacheLRU( 100 ); } /** @@ -102,8 +102,8 @@ class FileBackendDBRepoWrapper extends FileBackend { // @TODO: batching $resolved = []; foreach ( $paths as $i => $path ) { - if ( !$latest && $this->resolvedPathCache->has( $path, 'target', 10 ) ) { - $resolved[$i] = $this->resolvedPathCache->get( $path, 'target' ); + if ( !$latest && $this->resolvedPathCache->hasField( $path, 'target', 10 ) ) { + $resolved[$i] = $this->resolvedPathCache->getField( $path, 'target' ); continue; } @@ -127,12 +127,12 @@ class FileBackendDBRepoWrapper extends FileBackend { continue; } $resolved[$i] = $this->getPathForSHA1( $sha1 ); - $this->resolvedPathCache->set( $path, 'target', $resolved[$i] ); + $this->resolvedPathCache->setField( $path, 'target', $resolved[$i] ); } elseif ( $container === "{$this->repoName}-deleted" ) { $name = basename( $path ); // . $sha1 = substr( $name, 0, strpos( $name, '.' ) ); // ignore extension $resolved[$i] = $this->getPathForSHA1( $sha1 ); - $this->resolvedPathCache->set( $path, 'target', $resolved[$i] ); + $this->resolvedPathCache->setField( $path, 'target', $resolved[$i] ); } else { $resolved[$i] = $path; } diff --git a/includes/filerepo/RepoGroup.php b/includes/filerepo/RepoGroup.php index fa4567e0b2..90c8707f8d 100644 --- a/includes/filerepo/RepoGroup.php +++ b/includes/filerepo/RepoGroup.php @@ -98,7 +98,7 @@ class RepoGroup { function __construct( $localInfo, $foreignInfo ) { $this->localInfo = $localInfo; $this->foreignInfo = $foreignInfo; - $this->cache = new ProcessCacheLRU( self::MAX_CACHE_SIZE ); + $this->cache = new MapCacheLRU( self::MAX_CACHE_SIZE ); } /** @@ -141,8 +141,8 @@ class RepoGroup { && empty( $options['latest'] ) ) { $time = $options['time'] ?? ''; - if ( $this->cache->has( $dbkey, $time, 60 ) ) { - return $this->cache->get( $dbkey, $time ); + if ( $this->cache->hasField( $dbkey, $time, 60 ) ) { + return $this->cache->getField( $dbkey, $time ); } $useCache = true; } else { @@ -166,7 +166,7 @@ class RepoGroup { $image = $image ?: false; // type sanity # Cache file existence or non-existence if ( $useCache && ( !$image || $image->isCacheable() ) ) { - $this->cache->set( $dbkey, $time, $image ); + $this->cache->setField( $dbkey, $time, $image ); } return $image; -- 2.20.1