MediaWiki  1.23.8
MapCacheLRU Class Reference

Handles a simple LRU key/value map with a maximum number of entries. More...

Public Member Functions

 __construct ( $maxKeys)
 
 clear ( $keys=null)
 Clear one or several cache entries, or all cache entries. More...
 
 get ( $key)
 Get the value for a key. More...
 
 has ( $key)
 Check if a key exists. More...
 
 set ( $key, $value)
 Set a key/value pair. More...
 

Protected Member Functions

 ping ( $key)
 Push an entry to the top of the cache. More...
 

Protected Attributes

Array $cache = array()
 
 $maxCacheKeys
 

Detailed Description

Handles a simple LRU key/value map with a maximum number of entries.

Use ProcessCacheLRU if hierarchical purging is needed or objects can become stale

See also
ProcessCacheLRU
Since
1.23

Definition at line 33 of file MapCacheLRU.php.

Constructor & Destructor Documentation

◆ __construct()

MapCacheLRU::__construct (   $maxKeys)
Parameters
$maxKeysinteger Maximum number of entries allowed (min 1).
Exceptions
MWExceptionWhen $maxCacheKeys is not an int or =< 0.

Definition at line 42 of file MapCacheLRU.php.

Member Function Documentation

◆ clear()

MapCacheLRU::clear (   $keys = null)

Clear one or several cache entries, or all cache entries.

Parameters
$keysstring|Array
Returns
void

Definition at line 102 of file MapCacheLRU.php.

References $keys, array(), as, and cache.

◆ get()

MapCacheLRU::get (   $key)

Get the value for a key.

This returns null if the key is not set. If the item is already set, it will be pushed to the top of the cache.

Parameters
$keystring
Returns
mixed

Definition at line 87 of file MapCacheLRU.php.

References cache, and ping().

◆ has()

MapCacheLRU::has (   $key)

Check if a key exists.

Parameters
$keystring
Returns
bool

Definition at line 75 of file MapCacheLRU.php.

References cache.

◆ ping()

MapCacheLRU::ping (   $key)
protected

Push an entry to the top of the cache.

Parameters
$keystring

Definition at line 117 of file MapCacheLRU.php.

References cache.

Referenced by get(), and set().

◆ set()

MapCacheLRU::set (   $key,
  $value 
)

Set a key/value pair.

This will prune the cache if it gets too large based on LRU. If the item is already set, it will be pushed to the top of the cache.

Parameters
$keystring
$valuemixed
Returns
void

Definition at line 58 of file MapCacheLRU.php.

References $value, cache, key, and ping().

Member Data Documentation

◆ $cache

Array MapCacheLRU::$cache = array()
protected

Definition at line 34 of file MapCacheLRU.php.

◆ $maxCacheKeys

MapCacheLRU::$maxCacheKeys
protected

Definition at line 36 of file MapCacheLRU.php.


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