MediaWiki master
BlockCache.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Block;
4
6
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}
getPartialKey()
Get the bucket for the cache entry associated with this key.
clearUser(UserIdentity $user)
Clear all block cache entries associated with a user.
Interface for objects representing user identity.