From 220d30f8f4b803c38cbbe6735052566eea2576b1 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 20 Aug 2014 16:58:13 -0700 Subject: [PATCH] Bound the cache size of numberofWatchingusers() Change-Id: I60c9898318e340ee3c97d24b528d85a5f8c492e5 --- includes/changes/ChangesList.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/includes/changes/ChangesList.php b/includes/changes/ChangesList.php index 9b9c1029cf..536c6abc18 100644 --- a/includes/changes/ChangesList.php +++ b/includes/changes/ChangesList.php @@ -36,6 +36,9 @@ class ChangesList extends ContextSource { protected $rclistOpen; protected $rcMoveIndex; + /** @var MapCacheLRU */ + protected $watchingCache; + /** * Changeslist constructor * @@ -50,6 +53,7 @@ class ChangesList extends ContextSource { $this->skin = $obj; } $this->preCacheMessages(); + $this->watchingCache = new MapCacheLRU( 50 ); } /** @@ -460,14 +464,14 @@ class ChangesList extends ContextSource { * @return string */ protected function numberofWatchingusers( $count ) { - static $cache = array(); + $cache = $this->watchingCache; if ( $count > 0 ) { - if ( !isset( $cache[$count] ) ) { - $cache[$count] = $this->msg( 'number_of_watching_users_RCview' ) - ->numParams( $count )->escaped(); + if ( !$cache->has( $count ) ) { + $cache->set( $count, $this->msg( 'number_of_watching_users_RCview' ) + ->numParams( $count )->escaped() ); } - return $cache[$count]; + return $cache->get( $count ); } else { return ''; } -- 2.20.1