MediaWiki master
MediaWiki\User\ActorCache Class Reference

Simple in-memory cache for UserIdentity objects indexed by user ID, actor ID and user name. More...

Public Member Functions

 __construct (int $maxSize)
 
 add (int $actorId, UserIdentity $actor)
 Add $actor with $actorId to the cache.
 
 clear ()
 Remove everything from the cache.
 
 getActor (string $keyType, $keyValue)
 Get user identity which has $keyType equal to $keyValue.
 
 getActorId (string $keyType, $keyValue)
 Get actor ID of the user which has $keyType equal to $keyValue.
 
 remove (UserIdentity $actor)
 

Detailed Description

Simple in-memory cache for UserIdentity objects indexed by user ID, actor ID and user name.

We cannot just use MapCacheLRU for this because of eviction semantics: we need to be able to remove UserIdentity from the cache even if user ID or user name has changed, so we track the most accessed VALUES in the cache, not keys, and evict them alongside with all their indexes.

Since
1.37
Access: internal
For use by ActorStore

Definition at line 36 of file ActorCache.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\User\ActorCache::__construct ( int $maxSize)
Parameters
int$maxSizehold up to this many UserIdentity values

Definition at line 59 of file ActorCache.php.

Member Function Documentation

◆ add()

MediaWiki\User\ActorCache::add ( int $actorId,
UserIdentity $actor )

Add $actor with $actorId to the cache.

Parameters
int$actorId
UserIdentity$actor

Definition at line 88 of file ActorCache.php.

References MediaWiki\User\UserIdentity\getId(), MediaWiki\User\UserIdentity\getName(), and MediaWiki\DAO\WikiAwareEntity\getWikiId().

◆ clear()

MediaWiki\User\ActorCache::clear ( )

Remove everything from the cache.

Access: internal

Definition at line 121 of file ActorCache.php.

◆ getActor()

MediaWiki\User\ActorCache::getActor ( string $keyType,
$keyValue )

Get user identity which has $keyType equal to $keyValue.

Parameters
string$keyTypeone of self::KEY_* constants.
string | int$keyValue
Returns
UserIdentity|null

Definition at line 69 of file ActorCache.php.

◆ getActorId()

MediaWiki\User\ActorCache::getActorId ( string $keyType,
$keyValue )

Get actor ID of the user which has $keyType equal to $keyValue.

Parameters
string$keyTypeone of self::KEY_* constants.
string | int$keyValue
Returns
int|null

Definition at line 79 of file ActorCache.php.

◆ remove()

MediaWiki\User\ActorCache::remove ( UserIdentity $actor)

Definition at line 102 of file ActorCache.php.


The documentation for this class was generated from the following file: