From e5d71f2552893f15da9c0be7dd1fa210adb7be23 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 11 Jul 2018 13:54:51 +0100 Subject: [PATCH] Switch callers from ProcessCacheLRU to MapCacheLRU Change-Id: Iefe5c25e952079420b3241bc26efe1d2d086e6fb --- includes/PageProps.php | 22 +++++++++++----------- includes/jobqueue/JobQueueGroup.php | 12 ++++++------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/includes/PageProps.php b/includes/PageProps.php index ff8deee373..df2451c3a5 100644 --- a/includes/PageProps.php +++ b/includes/PageProps.php @@ -81,7 +81,7 @@ class PageProps { * Create a PageProps object */ private function __construct() { - $this->cache = new ProcessCacheLRU( self::CACHE_SIZE ); + $this->cache = new MapCacheLRU( self::CACHE_SIZE ); } /** @@ -89,8 +89,8 @@ class PageProps { * @param int $size */ public function ensureCacheSize( $size ) { - if ( $this->cache->getSize() < $size ) { - $this->cache->resize( $size ); + if ( $this->cache->getMaxSize() < $size ) { + $this->cache->setMaxSize( $size ); } } @@ -267,11 +267,11 @@ class PageProps { * @return string|bool property value array or false if not found */ private function getCachedProperty( $pageID, $propertyName ) { - if ( $this->cache->has( $pageID, $propertyName, self::CACHE_TTL ) ) { - return $this->cache->get( $pageID, $propertyName ); + if ( $this->cache->hasField( $pageID, $propertyName, self::CACHE_TTL ) ) { + return $this->cache->getField( $pageID, $propertyName ); } - if ( $this->cache->has( 0, $pageID, self::CACHE_TTL ) ) { - $pageProperties = $this->cache->get( 0, $pageID ); + if ( $this->cache->hasField( 0, $pageID, self::CACHE_TTL ) ) { + $pageProperties = $this->cache->getField( 0, $pageID ); if ( isset( $pageProperties[$propertyName] ) ) { return $pageProperties[$propertyName]; } @@ -286,8 +286,8 @@ class PageProps { * @return string|bool property value array or false if not found */ private function getCachedProperties( $pageID ) { - if ( $this->cache->has( 0, $pageID, self::CACHE_TTL ) ) { - return $this->cache->get( 0, $pageID ); + if ( $this->cache->hasField( 0, $pageID, self::CACHE_TTL ) ) { + return $this->cache->getField( 0, $pageID ); } return false; } @@ -300,7 +300,7 @@ class PageProps { * @param mixed $propertyValue value of property */ private function cacheProperty( $pageID, $propertyName, $propertyValue ) { - $this->cache->set( $pageID, $propertyName, $propertyValue ); + $this->cache->setField( $pageID, $propertyName, $propertyValue ); } /** @@ -311,6 +311,6 @@ class PageProps { */ private function cacheProperties( $pageID, $pageProperties ) { $this->cache->clear( $pageID ); - $this->cache->set( 0, $pageID, $pageProperties ); + $this->cache->setField( 0, $pageID, $pageProperties ); } } diff --git a/includes/jobqueue/JobQueueGroup.php b/includes/jobqueue/JobQueueGroup.php index addc7fc2e1..37c8890cc9 100644 --- a/includes/jobqueue/JobQueueGroup.php +++ b/includes/jobqueue/JobQueueGroup.php @@ -62,7 +62,7 @@ class JobQueueGroup { protected function __construct( $wiki, $readOnlyReason ) { $this->wiki = $wiki; $this->readOnlyReason = $readOnlyReason; - $this->cache = new ProcessCacheLRU( 10 ); + $this->cache = new MapCacheLRU( 10 ); } /** @@ -154,8 +154,8 @@ class JobQueueGroup { $this->get( $type )->push( $jobs ); } - if ( $this->cache->has( 'queues-ready', 'list' ) ) { - $list = $this->cache->get( 'queues-ready', 'list' ); + if ( $this->cache->hasField( 'queues-ready', 'list' ) ) { + $list = $this->cache->getField( 'queues-ready', 'list' ); if ( count( array_diff( array_keys( $jobsByType ), $list ) ) ) { $this->cache->clear( 'queues-ready' ); } @@ -244,10 +244,10 @@ class JobQueueGroup { } } else { // any job in the "default" jobs types if ( $flags & self::USE_CACHE ) { - if ( !$this->cache->has( 'queues-ready', 'list', self::PROC_CACHE_TTL ) ) { - $this->cache->set( 'queues-ready', 'list', $this->getQueuesWithJobs() ); + if ( !$this->cache->hasField( 'queues-ready', 'list', self::PROC_CACHE_TTL ) ) { + $this->cache->setField( 'queues-ready', 'list', $this->getQueuesWithJobs() ); } - $types = $this->cache->get( 'queues-ready', 'list' ); + $types = $this->cache->getField( 'queues-ready', 'list' ); } else { $types = $this->getQueuesWithJobs(); } -- 2.20.1