mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Gadgets
synced 2024-11-30 18:14:21 +00:00
Simplify code around injected srvCache/wanCache
Follows-up de999997e7
(I6c7967ef09).
Change-Id: I481331d411b68ed34cfd63b42348ae93d7f59b71
This commit is contained in:
parent
de999997e7
commit
9349b05a37
|
@ -44,7 +44,6 @@ class MediaWikiGadgetsDefinitionRepo extends GadgetRepo {
|
||||||
private IConnectionProvider $dbProvider;
|
private IConnectionProvider $dbProvider;
|
||||||
private WANObjectCache $wanCache;
|
private WANObjectCache $wanCache;
|
||||||
private RevisionLookup $revLookup;
|
private RevisionLookup $revLookup;
|
||||||
/** @var \BagOStuff */
|
|
||||||
private BagOStuff $srvCache;
|
private BagOStuff $srvCache;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
@ -87,11 +86,10 @@ class MediaWikiGadgetsDefinitionRepo extends GadgetRepo {
|
||||||
* Purge the definitions cache, for example when MediaWiki:Gadgets-definition is edited.
|
* Purge the definitions cache, for example when MediaWiki:Gadgets-definition is edited.
|
||||||
*/
|
*/
|
||||||
private function purgeDefinitionCache(): void {
|
private function purgeDefinitionCache(): void {
|
||||||
$srvCache = $this->srvCache;
|
|
||||||
$key = $this->makeDefinitionCacheKey( $this->wanCache );
|
$key = $this->makeDefinitionCacheKey( $this->wanCache );
|
||||||
|
|
||||||
$this->wanCache->delete( $key );
|
$this->wanCache->delete( $key );
|
||||||
$srvCache->delete( $key );
|
$this->srvCache->delete( $key );
|
||||||
$this->definitions = null;
|
$this->definitions = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,15 +129,13 @@ class MediaWikiGadgetsDefinitionRepo extends GadgetRepo {
|
||||||
//
|
//
|
||||||
// 1. process cache. Faster repeat calls.
|
// 1. process cache. Faster repeat calls.
|
||||||
if ( $this->definitions === null ) {
|
if ( $this->definitions === null ) {
|
||||||
$wanCache = $this->wanCache;
|
$key = $this->makeDefinitionCacheKey( $this->wanCache );
|
||||||
$srvCache = $this->srvCache;
|
$this->definitions = $this->srvCache->getWithSetCallback(
|
||||||
$key = $this->makeDefinitionCacheKey( $wanCache );
|
|
||||||
$this->definitions = $srvCache->getWithSetCallback(
|
|
||||||
$key,
|
$key,
|
||||||
// between 7 and 15 seconds to avoid memcached/lockTSE stampede (T203786)
|
// between 7 and 15 seconds to avoid memcached/lockTSE stampede (T203786)
|
||||||
mt_rand( 7, 15 ),
|
mt_rand( 7, 15 ),
|
||||||
function () use ( $wanCache, $key ) {
|
function () use ( $key ) {
|
||||||
return $wanCache->getWithSetCallback(
|
return $this->wanCache->getWithSetCallback(
|
||||||
$key,
|
$key,
|
||||||
// 1 day
|
// 1 day
|
||||||
Gadget::CACHE_TTL,
|
Gadget::CACHE_TTL,
|
||||||
|
|
Loading…
Reference in a new issue