MediaWiki
1.30.0
|
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... | |
getAllKeys () | |
getWithSetCallback ( $key, callable $callback) | |
Get an item with the given key, producing and setting it if not found. 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 = [] |
$maxCacheKeys | |
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
Definition at line 34 of file MapCacheLRU.php.
MapCacheLRU::__construct | ( | $maxKeys | ) |
int | $maxKeys | Maximum number of entries allowed (min 1). |
Exception | When $maxCacheKeys is not an int or not above zero. |
Definition at line 44 of file MapCacheLRU.php.
MapCacheLRU::clear | ( | $keys = null | ) |
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.
string | $key |
Definition at line 92 of file MapCacheLRU.php.
MapCacheLRU::getAllKeys | ( | ) |
MapCacheLRU::getWithSetCallback | ( | $key, | |
callable | $callback | ||
) |
Get an item with the given key, producing and setting it if not found.
If the callback returns false, then nothing is stored.
string | $key | |
callable | $callback | Callback that will produce the value |
Definition at line 120 of file MapCacheLRU.php.
MapCacheLRU::has | ( | $key | ) |
Check if a key exists.
string | $key |
Definition at line 77 of file MapCacheLRU.php.
References cache.
Referenced by get(), getWithSetCallback(), and set().
|
protected |
Push an entry to the top of the cache.
string | $key |
Definition at line 154 of file MapCacheLRU.php.
References cache.
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.
string | $key | |
mixed | $value |
Definition at line 60 of file MapCacheLRU.php.
References $value, cache, captcha-old\count, has(), key, and ping().
|
protected |
Definition at line 36 of file MapCacheLRU.php.
|
protected |
Definition at line 38 of file MapCacheLRU.php.