Final Class Yiisoft\Cache\DependencyAwareCache
| Inheritance | Yiisoft\Cache\DependencyAwareCache |
|---|---|
| Implements | Psr\SimpleCache\CacheInterface |
Cache provides support for the data caching, including dependencies.
The actual data caching is performed via {@see \Yiisoft\Cache\DependencyAwareCache::handler()}.
Public Methods
Method Details
| public mixed __construct ( Yiisoft\Cache\CacheInterface $cache, \Psr\SimpleCache\CacheInterface $handler ) | ||
| $cache | Yiisoft\Cache\CacheInterface |
The actual cache. |
| $handler | \Psr\SimpleCache\CacheInterface |
The actual cache handler. |
public function __construct(
private readonly CacheInterface $cache,
private readonly PsrSimpleCacheInterface $handler
) {
}
| public boolean delete ( mixed $key ) | ||
| $key | mixed | |
public function delete($key): bool
{
return $this->handler->delete($key);
}
| public boolean deleteMultiple ( mixed $keys ) | ||
| $keys | mixed | |
public function deleteMultiple($keys): bool
{
return $this->handler->deleteMultiple($keys);
}
| public mixed get ( string $key, mixed $default = null ) | ||
| $key | string | |
| $default | mixed | |
public function get(string $key, mixed $default = null): mixed
{
$value = $this->handler->get($key, $default);
return $this->checkAndGetValue($key, $value, $default);
}
| public iterable getMultiple ( iterable $keys, mixed $default = null ) | ||
| $keys | iterable | |
| $default | mixed | |
public function getMultiple(iterable $keys, mixed $default = null): iterable
{
$values = [];
foreach ($this->handler->getMultiple($keys, $default) as $key => $value) {
$values[$key] = $this->checkAndGetValue($key, $value, $default);
}
return $values;
}
Gets the raw cache value.
| public mixed getRaw ( string $key ) | ||
| $key | string |
The unique key of this item in the cache. |
| return | mixed |
The raw cache value or `null if the cache is outdated. |
|---|---|---|
public function getRaw(string $key)
{
return $this->handler->get($key);
}
| public boolean has ( string $key ) | ||
| $key | string | |
public function has(string $key): bool
{
return $this->get($key) !== null;
}
| public boolean set ( string $key, mixed $value, Yiisoft\Cache\Ttl|null|integer|DateInterval $ttl = null ) | ||
| $key | string | |
| $value | mixed | |
| $ttl | Yiisoft\Cache\Ttl|null|integer|DateInterval | |
public function set(string $key, mixed $value, Ttl|null|int|DateInterval $ttl = null): bool
{
return $this->handler->set($key, $value, Ttl::from($ttl)->toSeconds());
}
| public boolean setMultiple ( iterable $values, Yiisoft\Cache\Ttl|null|integer|DateInterval $ttl = null ) | ||
| $values | iterable | |
| $ttl | Yiisoft\Cache\Ttl|null|integer|DateInterval | |
public function setMultiple(iterable $values, Ttl|null|int|DateInterval $ttl = null): bool
{
return $this->handler->setMultiple($values, Ttl::from($ttl)->toSeconds());
}
Signup or Login in order to comment.