Switch $wgMemc usage to proper cache/stash usage

Change-Id: I688e21ff4ff999f11c0373ad611075c14fa5db2a
This commit is contained in:
Aaron Schulz 2016-04-22 11:58:03 -07:00
parent 748068b66c
commit 33fe3490d3
3 changed files with 8 additions and 12 deletions

View file

@ -22,9 +22,10 @@ interface EchoContainmentList {
* from multiple sources like global variables, wiki pages, etc.
*
* Initialize:
* $cache = ObjectCache::getLocalClusterIntance();
* $set = new EchoContainmentSet;
* $set->addArray( $wgSomeGlobalParameter );
* $set->addOnWiki( NS_USER, 'Foo/bar-baz', $wgMemc, 'some_user_specific_cache_key' );
* $set->addOnWiki( NS_USER, 'Foo/bar-baz', $cache, 'some_user_specific_cache_key' );
*
* Usage:
* if ( $set->contains( 'SomeUser' ) ) {

View file

@ -154,9 +154,7 @@ class MWEchoEmailBundler {
* Get the timestamp of last email
*/
protected function retrieveLastEmailTimestamp() {
global $wgMemc;
$data = $wgMemc->get( $this->getMemcacheKey() );
$data = ObjectCache::getMainStashInstance()->get( $this->getMemcacheKey() );
if ( $data !== false ) {
$this->timestamp = $data['timestamp'];
}
@ -279,12 +277,10 @@ class MWEchoEmailBundler {
* Update bundle email metadata for user/hash pair
*/
protected function updateEmailMetadata() {
global $wgMemc;
$key = $this->getMemcacheKey();
// Store new data and make it expire in 7 days
$wgMemc->set(
ObjectCache::getMainStashInstance()->set(
$key,
array(
'timestamp' => $this->timestamp

View file

@ -190,8 +190,7 @@ class EchoNotificationController {
}
if ( self::$blacklist === null ) {
global $wgEchoAgentBlacklist, $wgEchoOnWikiBlacklist,
$wgMemc;
global $wgEchoAgentBlacklist, $wgEchoOnWikiBlacklist;
self::$blacklist = new EchoContainmentSet;
self::$blacklist->addArray( $wgEchoAgentBlacklist );
@ -199,7 +198,7 @@ class EchoNotificationController {
self::$blacklist->addOnWiki(
NS_MEDIAWIKI,
$wgEchoOnWikiBlacklist,
$wgMemc,
ObjectCache::getLocalClusterInstance(),
wfMemcKey( "echo_on_wiki_blacklist" )
);
}
@ -216,7 +215,7 @@ class EchoNotificationController {
* @return boolean True when the event agent is in the user whitelist
*/
public static function isWhitelistedByUser( EchoEvent $event, User $user ) {
global $wgEchoPerUserWhitelistFormat, $wgMemc;
global $wgEchoPerUserWhitelistFormat;
if ( $wgEchoPerUserWhitelistFormat === null || !$event->getAgent() ) {
return false;
@ -232,7 +231,7 @@ class EchoNotificationController {
self::$userWhitelist[$userId]->addOnWiki(
NS_USER,
sprintf( $wgEchoPerUserWhitelistFormat, $user->getName() ),
$wgMemc,
ObjectCache::getLocalClusterInstance(),
wfMemcKey( "echo_on_wiki_whitelist_" . $userId )
);
}