MediaWiki
master
BlockCache.php
Go to the documentation of this file.
1
<?php
2
3
namespace
MediaWiki\Block
;
4
5
use
MediaWiki\User\UserIdentity
;
6
10
class
BlockCache
{
12
private
$cache = [];
13
22
public
function
get
(
BlockCacheKey
$key ) {
23
$entry = $this->cache[$key->getPartialKey()] ??
null
;
24
if
( $entry ===
null
) {
25
return
null
;
26
}
27
return
$key->matchesStored( $entry->key ) ? $entry->block :
null
;
28
}
29
37
public
function
set
(
BlockCacheKey
$key, $value ) {
38
$this->cache[$key->
getPartialKey
()] =
new
BlockCacheEntry
( $key, $value );
39
}
40
46
public
function
clearUser
(
UserIdentity
$user ) {
47
foreach
( $this->cache as $partialKey => $entry ) {
48
if
( $entry->key->isUser( $user ) ) {
49
unset( $this->cache[$partialKey] );
50
}
51
}
52
}
53
}
MediaWiki\Block\BlockCacheEntry
Definition
BlockCacheEntry.php:8
MediaWiki\Block\BlockCacheKey
Definition
BlockCacheKey.php:13
MediaWiki\Block\BlockCacheKey\getPartialKey
getPartialKey()
Get the bucket for the cache entry associated with this key.
Definition
BlockCacheKey.php:83
MediaWiki\Block\BlockCache
Definition
BlockCache.php:10
MediaWiki\Block\BlockCache\clearUser
clearUser(UserIdentity $user)
Clear all block cache entries associated with a user.
Definition
BlockCache.php:46
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition
UserIdentity.php:39
MediaWiki\Block
Definition
AbstractBlock.php:21
includes
block
BlockCache.php
Generated on Wed Dec 11 2024 21:23:14 for MediaWiki by
1.10.0