MediaWiki REL1_37
MediaWiki\User\ActorCache Class Reference

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)
 Remove $actor from cache.
 

Private Member Functions

 getCachedValue (string $keyType, $keyValue)
 
 ping (int $actorId)
 Record the actor with $actorId was recently used.
 

Private Attributes

array[][] $cache = [ self::KEY_ACTOR_ID => [], self::KEY_USER_NAME => [], self::KEY_USER_ID => [] ]
 Contains 3 keys, KEY_ACTOR_ID, KEY_USER_ID, and KEY_USER_NAME, each of which has a value of an array of arrays with actor ids and UserIdentity objects, keyed with the corresponding actor id/user id/user name.
 
int $maxSize
 

Detailed Description

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 60 of file ActorCache.php.

References MediaWiki\User\ActorCache\$maxSize.

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 89 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 127 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 70 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 80 of file ActorCache.php.

◆ getCachedValue()

MediaWiki\User\ActorCache::getCachedValue ( string  $keyType,
  $keyValue 
)
private
Parameters
string$keyTypeone of self::KEY_* constants.
string | int$keyValue
Returns
array|null [ 'actor' => UserIdentity, 'actorId' => int ]

Definition at line 136 of file ActorCache.php.

◆ ping()

MediaWiki\User\ActorCache::ping ( int  $actorId)
private

Record the actor with $actorId was recently used.

Parameters
int$actorId

Definition at line 149 of file ActorCache.php.

◆ remove()

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

Remove $actor from cache.

Parameters
UserIdentity$actor

Definition at line 108 of file ActorCache.php.

Member Data Documentation

◆ $cache

array [][] MediaWiki\User\ActorCache::$cache = [ self::KEY_ACTOR_ID => [], self::KEY_USER_NAME => [], self::KEY_USER_ID => [] ]
private

Contains 3 keys, KEY_ACTOR_ID, KEY_USER_ID, and KEY_USER_NAME, each of which has a value of an array of arrays with actor ids and UserIdentity objects, keyed with the corresponding actor id/user id/user name.

Definition at line 55 of file ActorCache.php.

◆ $maxSize

int MediaWiki\User\ActorCache::$maxSize
private
Initial value:
=
public const KEY_USER_NAME 'name'

Definition at line 48 of file ActorCache.php.

Referenced by MediaWiki\User\ActorCache\__construct().


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