Final Class Yiisoft\Cache\Metadata\CacheItems
| Inheritance | Yiisoft\Cache\Metadata\CacheItems |
|---|
CacheItems store the metadata of each cache item.
Public 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
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);
}
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]);
}
}
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());
}
Signup or Login in order to comment.