Final Class Yiisoft\Cache\Metadata\CacheItems
| Inheritance | Yiisoft\ |
|---|
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\ |
| remove() | Removes a cache item with the specified key. | Yiisoft\ |
| set() | Adds or updates a cache item. | Yiisoft\ |
Method Details
Checks whether the dependency has been changed or whether the cache expired.
| public boolean expired ( string $key, float $beta, Yiisoft\ | ||
| $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\ |
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\ | ||
| $item | Yiisoft\ |
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());
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.