X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fcache%2FMapCacheLRU.php;h=a22d8023d64ca09cad42ab504e04b72ed1bd6ab2;hb=e696a662a96209e642fce66cb861ad18dc5a2371;hp=3539d8fca2be4d95a20fbf8194da95489b8b21e9;hpb=da42257e35682db692accabee6864e40a272243d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/cache/MapCacheLRU.php b/includes/cache/MapCacheLRU.php index 3539d8fca2..a22d8023d6 100644 --- a/includes/cache/MapCacheLRU.php +++ b/includes/cache/MapCacheLRU.php @@ -28,15 +28,16 @@ * * @see ProcessCacheLRU * @ingroup Cache + * @since 1.23 */ class MapCacheLRU { - /** @var Array */ + /** @var array */ protected $cache = array(); // (key => value) protected $maxCacheKeys; // integer; max entries /** - * @param $maxKeys integer Maximum number of entries allowed (min 1). + * @param int $maxKeys Maximum number of entries allowed (min 1). * @throws MWException When $maxCacheKeys is not an int or =< 0. */ public function __construct( $maxKeys ) { @@ -51,8 +52,8 @@ class MapCacheLRU { * 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. * - * @param $key string - * @param $value mixed + * @param string $key + * @param mixed $value * @return void */ public function set( $key, $value ) { @@ -66,13 +67,22 @@ class MapCacheLRU { $this->cache[$key] = $value; } + /** + * Check if a key exists + * + * @param string $key + * @return bool + */ + public function has( $key ) { + return isset( $this->cache[$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. * - * @param $key string - * @param $prop string + * @param string $key * @return mixed */ public function get( $key ) { @@ -87,7 +97,7 @@ class MapCacheLRU { /** * Clear one or several cache entries, or all cache entries * - * @param $keys string|Array + * @param string|array $keys * @return void */ public function clear( $keys = null ) { @@ -103,7 +113,7 @@ class MapCacheLRU { /** * Push an entry to the top of the cache * - * @param $key string + * @param string $key */ protected function ping( $key ) { $item = $this->cache[$key];