MediaWiki  REL1_31
ProcessCacheLRU Class Reference

Class for process caching individual properties of expiring items. More...

Inheritance diagram for ProcessCacheLRU:

Public Member Functions

 __construct ( $maxKeys)
 
 clear ( $keys=null)
 Clear one or several cache entries, or all cache entries. More...
 
 get ( $key, $prop)
 Get a property field for a cache entry. More...
 
 getSize ()
 Get cache size. More...
 
 has ( $key, $prop, $maxAge=0.0)
 Check if a property field exists for a cache entry. More...
 
 resize ( $maxKeys)
 Resize the maximum number of cache entries, removing older entries as needed. More...
 
 set ( $key, $prop, $value)
 Set a property field for a cache entry. More...
 

Protected Member Functions

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

Protected Attributes

array $cache = []
 
array $cacheTimes = []
 
 $maxCacheKeys
 

Detailed Description

Class for process caching individual properties of expiring items.

When the key for an entire item is deleted, all properties for it are deleted

Definition at line 32 of file ProcessCacheLRU.php.

Constructor & Destructor Documentation

◆ __construct()

ProcessCacheLRU::__construct (   $maxKeys)
Parameters
int$maxKeysMaximum number of entries allowed (min 1).
Exceptions
UnexpectedValueExceptionWhen $maxCacheKeys is not an int or =< 0.

Definition at line 45 of file ProcessCacheLRU.php.

References resize().

Member Function Documentation

◆ clear()

ProcessCacheLRU::clear (   $keys = null)

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

Parameters
string | array$keys
Returns
void

Definition at line 113 of file ProcessCacheLRU.php.

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

◆ get()

ProcessCacheLRU::get (   $key,
  $prop 
)

Get a property field for a cache entry.

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

Parameters
string$key
string$prop
Returns
mixed

Definition at line 99 of file ProcessCacheLRU.php.

References cache, and ping().

Referenced by JobQueueGroup\queuesHaveJobs().

◆ getSize()

ProcessCacheLRU::getSize ( )

Get cache size.

Returns
int

Definition at line 160 of file ProcessCacheLRU.php.

References $maxCacheKeys.

◆ has()

ProcessCacheLRU::has (   $key,
  $prop,
  $maxAge = 0.0 
)

Check if a property field exists for a cache entry.

Parameters
string$key
string$prop
float$maxAgeIgnore items older than this many seconds (since 1.21)
Returns
bool

Definition at line 80 of file ProcessCacheLRU.php.

References cache.

◆ ping()

ProcessCacheLRU::ping (   $key)
protected

Push an entry to the top of the cache.

Parameters
string$key

Definition at line 150 of file ProcessCacheLRU.php.

References cache.

Referenced by get(), and set().

◆ resize()

ProcessCacheLRU::resize (   $maxKeys)

Resize the maximum number of cache entries, removing older entries as needed.

Parameters
int$maxKeys
Returns
void
Exceptions
UnexpectedValueException

Definition at line 132 of file ProcessCacheLRU.php.

References cache, and key.

Referenced by __construct().

◆ set()

ProcessCacheLRU::set (   $key,
  $prop,
  $value 
)

Set a property field for a cache entry.

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
string$key
string$prop
mixed$value
Returns
void

Definition at line 59 of file ProcessCacheLRU.php.

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

Referenced by JobQueueGroup\push().

Member Data Documentation

◆ $cache

array ProcessCacheLRU::$cache = []
protected

Definition at line 34 of file ProcessCacheLRU.php.

◆ $cacheTimes

array ProcessCacheLRU::$cacheTimes = []
protected

Definition at line 37 of file ProcessCacheLRU.php.

◆ $maxCacheKeys

ProcessCacheLRU::$maxCacheKeys
protected

Definition at line 39 of file ProcessCacheLRU.php.

Referenced by getSize().


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