mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SpamBlacklist
synced 2024-11-15 03:13:58 +00:00
Conversion to using WAN cache
Bug: T93141 Change-Id: I67fa3e6e6d348953472a565bdbeccd8298c80f58
This commit is contained in:
parent
6cc59ba5ee
commit
ca55c42a1e
12
BaseBlacklist.php
Normal file → Executable file
12
BaseBlacklist.php
Normal file → Executable file
|
@ -221,7 +221,7 @@ abstract class BaseBlacklist {
|
|||
* @return array
|
||||
*/
|
||||
function getSharedBlacklists() {
|
||||
global $wgMemc, $wgDBname;
|
||||
global $wgDBname;
|
||||
$listType = $this->getBlacklistType();
|
||||
|
||||
wfDebugLog( 'SpamBlacklist', "Loading $listType regex..." );
|
||||
|
@ -232,25 +232,27 @@ abstract class BaseBlacklist {
|
|||
return array();
|
||||
}
|
||||
|
||||
$cache = ObjectCache::getMainWANInstance();
|
||||
// This used to be cached per-site, but that could be bad on a shared
|
||||
// server where not all wikis have the same configuration.
|
||||
$cachedRegexes = $wgMemc->get( "$wgDBname:{$listType}_blacklist_regexes" );
|
||||
$cachedRegexes = $cache->get( "$wgDBname:{$listType}_blacklist_regexes" );
|
||||
if( is_array( $cachedRegexes ) ) {
|
||||
wfDebugLog( 'SpamBlacklist', "Got shared spam regexes from cache\n" );
|
||||
return $cachedRegexes;
|
||||
}
|
||||
|
||||
$regexes = $this->buildSharedBlacklists();
|
||||
$wgMemc->set( "$wgDBname:{$listType}_blacklist_regexes", $regexes, $this->expiryTime );
|
||||
$cache->set( "$wgDBname:{$listType}_blacklist_regexes", $regexes, $this->expiryTime );
|
||||
|
||||
return $regexes;
|
||||
}
|
||||
|
||||
function clearCache() {
|
||||
global $wgMemc, $wgDBname;
|
||||
global $wgDBname;
|
||||
$listType = $this->getBlacklistType();
|
||||
|
||||
$wgMemc->delete( "$wgDBname:{$listType}_blacklist_regexes" );
|
||||
$cache = ObjectCache::getMainWANInstance();
|
||||
$cache->delete( "$wgDBname:{$listType}_blacklist_regexes" );
|
||||
wfDebugLog( 'SpamBlacklist', "$listType blacklist local cache cleared.\n" );
|
||||
}
|
||||
|
||||
|
|
5
SpamBlacklistHooks.php
Normal file → Executable file
5
SpamBlacklistHooks.php
Normal file → Executable file
|
@ -212,11 +212,12 @@ class SpamBlacklistHooks {
|
|||
if( !BaseBlacklist::isLocalSource( $wikiPage->getTitle() ) ) {
|
||||
return true;
|
||||
}
|
||||
global $wgMemc, $wgDBname;
|
||||
global $wgDBname;
|
||||
|
||||
$cache = ObjectCache::getMainWANInstance();
|
||||
// This sucks because every Blacklist needs to be cleared
|
||||
foreach ( BaseBlacklist::getBlacklistTypes() as $type => $class ) {
|
||||
$wgMemc->delete( "$wgDBname:{$type}_blacklist_regexes" );
|
||||
$cache->delete( "$wgDBname:{$type}_blacklist_regexes" );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue