use Wikimedia\Assert\Assert;
/**
- * Handles per process caching of items
+ * Class for process caching individual properties of expiring items
+ *
+ * When the key for an entire item is deleted, all properties for it are deleted
+ *
* @ingroup Cache
*/
class ProcessCacheLRU {
- /** @var Array */
- protected $cache = array(); // (key => prop => value)
+ /** @var array */
+ protected $cache = []; // (key => prop => value)
- /** @var Array */
- protected $cacheTimes = array(); // (key => prop => UNIX timestamp)
+ /** @var array */
+ protected $cacheTimes = []; // (key => prop => UNIX timestamp)
protected $maxCacheKeys; // integer; max entries
*/
public function clear( $keys = null ) {
if ( $keys === null ) {
- $this->cache = array();
- $this->cacheTimes = array();
+ $this->cache = [];
+ $this->cacheTimes = [];
} else {
foreach ( (array)$keys as $key ) {
unset( $this->cache[$key] );
unset( $this->cache[$key] );
$this->cache[$key] = $item;
}
+
+ /**
+ * Get cache size
+ * @return int
+ */
+ public function getSize() {
+ return $this->maxCacheKeys;
+ }
}