jenkins-bot has submitted this change and it was merged. Change subject: Allow requiring cache size for page props ......................................................................
Allow requiring cache size for page props Needed for batch processing where size of the batch is known and the batch should fit in cache. Change-Id: Ib6d6e6ab7e12788c934cd0e973bc35e133aeccbb --- M includes/PageProps.php M includes/libs/ProcessCacheLRU.php 2 files changed, 19 insertions(+), 1 deletion(-) Approvals: Anomie: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/PageProps.php b/includes/PageProps.php index 3654384..5579ba5 100644 --- a/includes/PageProps.php +++ b/includes/PageProps.php @@ -85,6 +85,16 @@ } /** + * Ensure that cache has at least this size + * @param int $size + */ + public function ensureCacheSize( $size ) { + if ( $this->cache->getSize() < $size ) { + $this->cache->resize( $size ); + } + } + + /** * Given one or more Titles and one or more names of properties, * returns an associative array mapping page ID to property value. * Pages in the provided set of Titles that do not have a value for @@ -92,7 +102,7 @@ * single Title is provided, it does not need to be passed in an array, * but an array will always be returned. If a single property name is * provided, it does not need to be passed in an array. In that case, - * an associtive array mapping page ID to property value will be + * an associative array mapping page ID to property value will be * returned; otherwise, an associative array mapping page ID to * an associative array mapping property name to property value will be * returned. An empty array will be returned if no matching properties diff --git a/includes/libs/ProcessCacheLRU.php b/includes/libs/ProcessCacheLRU.php index 5a93391..03e23ed 100644 --- a/includes/libs/ProcessCacheLRU.php +++ b/includes/libs/ProcessCacheLRU.php @@ -149,4 +149,12 @@ unset( $this->cache[$key] ); $this->cache[$key] = $item; } + + /** + * Get cache size + * @return int + */ + public function getSize() { + return $this->maxCacheKeys; + } } -- To view, visit https://gerrit.wikimedia.org/r/305449 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib6d6e6ab7e12788c934cd0e973bc35e133aeccbb Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Smalyshev <smalys...@wikimedia.org> Gerrit-Reviewer: Anomie <bjor...@wikimedia.org> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: Smalyshev <smalys...@wikimedia.org> Gerrit-Reviewer: Tim Starling <tstarl...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits