jenkins-bot has submitted this change and it was merged.
Change subject: Removed caching config variables and always enable caching
......................................................................
Removed caching config variables and always enable caching
* APC will be used if around as a tier 1 cache
* This also makes it easier to have mixed zend/hhvm servers
Bug: T106743
Change-Id: Ie9f234753f78215441474dddc4eadedbd2b76ad7
---
M Gadgets_body.php
M extension.json
2 files changed, 38 insertions(+), 49 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Gadgets_body.php b/Gadgets_body.php
old mode 100644
new mode 100755
index 02d1d86..04c37dc
--- a/Gadgets_body.php
+++ b/Gadgets_body.php
@@ -355,58 +355,51 @@
return self::$definitionCache; // process cache hit
}
- $config = ConfigFactory::getDefaultInstance()->makeConfig(
'gadgets' );
// Ideally $t1Cache is APC, and $wanCache is memcached
- $t1Cache = $config->get( 'GadgetsCacheType' )
- ? ObjectCache::getInstance( $config->get(
'GadgetsCacheType' ) )
- : ObjectCache::getInstance( CACHE_NONE );
+ $t1Cache = ObjectCache::newAccelerator( array(), 'hash' );
$wanCache = ObjectCache::getMainWANInstance();
$key = wfMemcKey( 'gadgets-definition',
self::GADGET_CLASS_VERSION );
- if ( $config->get( 'GadgetsCaching' ) ) {
- // (a) Check the tier 1 cache
- $value = $t1Cache->get( $key );
- // Check if it passes a blind TTL check (avoids I/O)
- if ( $value && ( microtime( true ) - $value['time'] ) <
10 ) {
- self::$definitionCache = $value['gadgets']; //
process cache
- return self::$definitionCache;
- }
- // Cache generated after the "check" time should be
up-to-date
- $ckTime = $wanCache->getCheckKeyTime( $key ) +
WANObjectCache::HOLDOFF_TTL;
- if ( $value && $value['time'] > $ckTime ) {
- self::$definitionCache = $value['gadgets']; //
process cache
- return self::$definitionCache;
- }
-
- // (b) Fetch value from WAN cache or regenerate if
needed.
- // This is hit occasionally and more so when the list
changes.
- $value = $wanCache->getWithSetCallback(
- $key,
- function( $old, &$ttl ) {
- $now = microtime( true );
- $gadgets =
Gadget::fetchStructuredList();
- if ( $gadgets === false ) {
- $ttl =
WANObjectCache::TTL_UNCACHEABLE;
- }
-
- return array( 'gadgets' => $gadgets,
'time' => $now );
- },
- self::CACHE_TTL,
- array( $key ),
- array( 'lockTSE' => 300 )
- );
-
- // Update the tier 1 cache as needed
- if ( $value['gadgets'] !== false && $value['time'] >
$ckTime ) {
- // Set a modest TTL to keep the WAN key in cache
- $t1Cache->set( $key, $value, mt_rand( 300, 600
) );
- }
-
+ // (a) Check the tier 1 cache
+ $value = $t1Cache->get( $key );
+ // Check if it passes a blind TTL check (avoids I/O)
+ if ( $value && ( microtime( true ) - $value['time'] ) < 10 ) {
self::$definitionCache = $value['gadgets']; // process
cache
- } else {
- self::$definitionCache = self::fetchStructuredList();
// process cache
+ return self::$definitionCache;
}
+ // Cache generated after the "check" time should be up-to-date
+ $ckTime = $wanCache->getCheckKeyTime( $key ) +
WANObjectCache::HOLDOFF_TTL;
+ if ( $value && $value['time'] > $ckTime ) {
+ self::$definitionCache = $value['gadgets']; // process
cache
+ return self::$definitionCache;
+ }
+
+ // (b) Fetch value from WAN cache or regenerate if needed.
+ // This is hit occasionally and more so when the list changes.
+ $value = $wanCache->getWithSetCallback(
+ $key,
+ function( $old, &$ttl ) {
+ $now = microtime( true );
+ $gadgets = Gadget::fetchStructuredList();
+ if ( $gadgets === false ) {
+ $ttl = WANObjectCache::TTL_UNCACHEABLE;
+ }
+
+ return array( 'gadgets' => $gadgets, 'time' =>
$now );
+ },
+ self::CACHE_TTL,
+ array( $key ),
+ array( 'lockTSE' => 300 )
+ );
+
+ // Update the tier 1 cache as needed
+ if ( $value['gadgets'] !== false && $value['time'] > $ckTime ) {
+ // Set a modest TTL to keep the WAN key in cache
+ $t1Cache->set( $key, $value, mt_rand( 300, 600 ) );
+ }
+
+ self::$definitionCache = $value['gadgets']; // process cache
return self::$definitionCache;
}
diff --git a/extension.json b/extension.json
old mode 100644
new mode 100755
index 1e1e2b7..708b6f4
--- a/extension.json
+++ b/extension.json
@@ -54,9 +54,5 @@
"ConfigRegistry": {
"gadgets": "GlobalVarConfig::newInstance"
},
- "config": {
- "GadgetsCaching": true,
- "GadgetsCacheType": false
- },
"manifest_version": 1
}
--
To view, visit https://gerrit.wikimedia.org/r/226632
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie9f234753f78215441474dddc4eadedbd2b76ad7
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Gadgets
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits