MediaWiki
REL1_24
|
Persistent bloom filter used to avoid expensive lookups. More...
Public Member Functions | |
__construct (array $config) | |
Create a new bloom cache instance from configuration. | |
add ($key, $members) | |
Add a member to the bloom filter at $key. | |
check ($domain, $type, $member) | |
Check if a member is set in the bloom filter. | |
delete ($key) | |
Destroy a bloom filter at $key. | |
getScopedLock ($virtualKey) | |
Get an exclusive lock on a filter for updates. | |
getStatus ($virtualKey) | |
Get the status map of the virtual bloom filter at $key. | |
init ($key, $size=1000000, $precision=.001) | |
Create a new bloom filter at $key (if one does not exist yet) | |
insert ($domain, $type, $members) | |
Inform the bloom filter of a new member in order to keep it up to date. | |
isHit ($key, $member) | |
Check if a member is set in the bloom filter. | |
setStatus ($virtualKey, array $values) | |
Set the status map of the virtual bloom filter at $key. | |
Static Public Member Functions | |
static | get ($id) |
Protected Member Functions | |
doAdd ($key, array $members) | |
doDelete ($key) | |
doGetStatus ($key) | |
doInit ($key, $size, $precision) | |
doIsHit ($key, $member) | |
doSetStatus ($virtualKey, array $values) | |
Protected Attributes | |
string | $cacheID |
Unique ID for key namespacing *. | |
Static Protected Attributes | |
static | $instances = array() |
Persistent bloom filter used to avoid expensive lookups.
Definition at line 27 of file BloomCache.php.
BloomCache::__construct | ( | array $ | config | ) |
Create a new bloom cache instance from configuration.
This should only be called from within BloomCache.
array | $config | Parameters include:
|
Reimplemented in EmptyBloomCache, and BloomCacheRedis.
Definition at line 63 of file BloomCache.php.
BloomCache::add | ( | $ | key, |
$ | members | ||
) | [final] |
Add a member to the bloom filter at $key.
string | $key | |
string | array | $members |
Definition at line 174 of file BloomCache.php.
Referenced by BloomFilterTitleHasLogs\merge().
BloomCache::check | ( | $ | domain, |
$ | type, | ||
$ | member | ||
) | [final] |
Check if a member is set in the bloom filter.
A member being set means that it *might* have been added. A member not being set means it *could not* have been added.
This abstracts over isHit() to deal with filter updates and readiness. A class must exist with the name BloomFilter<type> and a static public mergeAndCheck() method. The later takes the following arguments: (BloomCache $bcache, $domain, $virtualKey, array $status) The method should return a bool indicating whether to use the filter.
The 'shared' bloom key must be used for any updates and will be used for the membership check if the method returns true. Since the key is shared, the method should never use delete(). The filter cannot be used in cases where membership in the filter needs to be taken away. In such cases, code *cannot* use this method - instead, it can directly use the other BloomCache methods to manage custom filters with their own keys (e.g. not 'shared').
string | $domain | |
string | $type | |
string | $member |
Definition at line 94 of file BloomCache.php.
BloomCache::delete | ( | $ | key | ) | [final] |
Destroy a bloom filter at $key.
string | $key |
Definition at line 205 of file BloomCache.php.
BloomCache::doAdd | ( | $ | key, |
array $ | members | ||
) | [abstract, protected] |
string | $key | |
array | $members |
Reimplemented in EmptyBloomCache, and BloomCacheRedis.
BloomCache::doDelete | ( | $ | key | ) | [abstract, protected] |
BloomCache::doGetStatus | ( | $ | key | ) | [abstract, protected] |
BloomCache::doInit | ( | $ | key, |
$ | size, | ||
$ | precision | ||
) | [abstract, protected] |
string | $key | |
integer | $size | Bit length |
float | $precision |
Reimplemented in EmptyBloomCache, and BloomCacheRedis.
BloomCache::doIsHit | ( | $ | key, |
$ | member | ||
) | [abstract, protected] |
string | $key | |
string | $member |
Reimplemented in EmptyBloomCache, and BloomCacheRedis.
BloomCache::doSetStatus | ( | $ | virtualKey, |
array $ | values | ||
) | [abstract, protected] |
string | $virtualKey | |
array | $values |
Reimplemented in EmptyBloomCache, and BloomCacheRedis.
static BloomCache::get | ( | $ | id | ) | [static, final] |
string | $id |
Definition at line 37 of file BloomCache.php.
Referenced by PopulateBloomFilter\execute(), BloomCacheRedisTest\setUp(), BloomCacheRedisTest\tearDown(), and BloomCacheRedisTest\testBloomCache().
BloomCache::getScopedLock | ( | $ | virtualKey | ) |
Get an exclusive lock on a filter for updates.
string | $virtualKey |
Reimplemented in BloomCacheRedis.
Definition at line 248 of file BloomCache.php.
Referenced by BloomFilterTitleHasLogs\mergeAndCheck().
BloomCache::getStatus | ( | $ | virtualKey | ) | [final] |
Get the status map of the virtual bloom filter at $key.
The map includes:
string | $virtualKey |
Definition at line 236 of file BloomCache.php.
BloomCache::init | ( | $ | key, |
$ | size = 1000000 , |
||
$ | precision = .001 |
||
) | [final] |
Create a new bloom filter at $key (if one does not exist yet)
string | $key | |
integer | $size | Bit length [default: 1000000] |
float | $precision | [default: .001] |
Definition at line 161 of file BloomCache.php.
BloomCache::insert | ( | $ | domain, |
$ | type, | ||
$ | members | ||
) | [final] |
Inform the bloom filter of a new member in order to keep it up to date.
string | $domain | |
string | $type | |
string | array | $members |
Definition at line 132 of file BloomCache.php.
BloomCache::isHit | ( | $ | key, |
$ | member | ||
) | [final] |
Check if a member is set in the bloom filter.
A member being set means that it *might* have been added. A member not being set means it *could not* have been added.
If this returns true, then the caller usually should do the expensive check (whatever that may be). It can be avoided otherwise.
string | $key | |
string | $member |
Definition at line 193 of file BloomCache.php.
BloomCache::setStatus | ( | $ | virtualKey, |
array $ | values | ||
) | [final] |
Set the status map of the virtual bloom filter at $key.
string | $virtualKey | |
array | $values | Map including some of (lastID, asOfTime, epoch) |
Definition at line 218 of file BloomCache.php.
Referenced by BloomFilterTitleHasLogs\merge().
string BloomCache::$cacheID [protected] |
Unique ID for key namespacing *.
Definition at line 28 of file BloomCache.php.
BloomCache::$instances = array() [static, protected] |
Definition at line 31 of file BloomCache.php.