0 follower

Final Class Yiisoft\Cache\Metadata\CacheItems

InheritanceYiisoft\Cache\Metadata\CacheItems

CacheItems store the metadata of each cache item.

Public Methods

Hide inherited methods

Method Description Defined By
expired() Checks whether the dependency has been changed or whether the cache expired. Yiisoft\Cache\Metadata\CacheItems
remove() Removes a cache item with the specified key. Yiisoft\Cache\Metadata\CacheItems
set() Adds or updates a cache item. Yiisoft\Cache\Metadata\CacheItems

Method Details

Hide inherited methods

expired() public method

Checks whether the dependency has been changed or whether the cache expired.

public boolean expired ( string $key, float $beta, Yiisoft\Cache\CacheInterface $cache )
$key string

The key that identifies the cache item.

$beta float

The value for calculating the range that is used for "Probably early expiration" algorithm.

$cache Yiisoft\Cache\CacheInterface

The actual cache handler.

return boolean

Whether the dependency has been changed or whether the cache expired.

                public function expired(string $key, float $beta, CacheInterface $cache): bool
{
    return isset($this->items[$key]) && $this->items[$key]->expired($beta, $cache);
}

            
remove() public method

Removes a cache item with the specified key.

public void remove ( string $key )
$key string

The key that identifies the cache item.

                public function remove(string $key): void
{
    if (isset($this->items[$key])) {
        unset($this->items[$key]);
    }
}

            
set() public method

Adds or updates a cache item.

public void set ( Yiisoft\Cache\Metadata\CacheItem $item )
$item Yiisoft\Cache\Metadata\CacheItem

The cache item.

                public function set(CacheItem $item): void
{
    $key = $item->key();
    if (!isset($this->items[$key])) {
        $this->items[$key] = $item;
        return;
    }
    $this->items[$key]->update($item->expiry(), $item->dependency());
}