EBernhardson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/292773

Change subject: Cache phrase suggest settings
......................................................................

Cache phrase suggest settings

I was profiling our test suite and this came up at 6% of the total
runtime. It's not a crazy amount, but it's significant enough we could
probably throw it into the local cache and give our users (and our
tests) a better experience.

Change-Id: Idb4897fe8a2eda7a019db3a661a0671bcffe3bab
---
M profiles/PhraseSuggesterProfiles.php
1 file changed, 12 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch 
refs/changes/73/292773/1

diff --git a/profiles/PhraseSuggesterProfiles.php 
b/profiles/PhraseSuggesterProfiles.php
index 77ebc5a..5c923db 100644
--- a/profiles/PhraseSuggesterProfiles.php
+++ b/profiles/PhraseSuggesterProfiles.php
@@ -223,11 +223,18 @@
                        $wgCirrusSearchPhraseSuggestPrefixLengthHardLimit,
                        $wgCirrusSearchPhraseSuggestAllowedMode;
 
-               $source = wfMessage( 'cirrussearch-didyoumean-settings' 
)->inContentLanguage();
-               if ( !$source || $source->isDisabled() ) {
-                       return;
-               }
-               $lines = Util::parseSettingsInMessage( $source->plain() );
+               $cache = \ObjectCache::getLocalServerInstance()
+               $lines = $cache->getWithSetCallback(
+                       $cache->makeKey( 'cirrussearch-didyoumean-settings' ),
+                       600,
+                       function () {
+                               $source = wfMessage( 
'cirrussearch-didyoumean-settings' )->inContentLanguage();
+                               if ( !$source || $source->isDisabled() ) {
+                                       return array()
+                               }
+                               return Util::parseSettingsInMessage( 
$source->plain() );
+                       }
+               );
 
                // Keep original alpha or discount settings
                if ( isset ( 
$wgCirrusSearchPhraseSuggestSettings['smoothing_model']['laplace']['alpha'] ) ) 
{

-- 
To view, visit https://gerrit.wikimedia.org/r/292773
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idb4897fe8a2eda7a019db3a661a0671bcffe3bab
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <ebernhard...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to