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 \Yiisoft\Cache\DependencyAwareCache::handler().
Public Methods
Method Details
| public __construct( Yiisoft\Cache\CacheInterface $cache, \Psr\SimpleCache\CacheInterface $handler ): mixed | ||
| $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 delete( mixed $key ): boolean | ||
| $key | mixed | |
public function delete($key): bool
{
return $this->handler->delete($key);
}
| public deleteMultiple( mixed $keys ): boolean | ||
| $keys | mixed | |
public function deleteMultiple($keys): bool
{
return $this->handler->deleteMultiple($keys);
}
| public get( string $key, mixed $default = null ): mixed | ||
| $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 getMultiple( iterable $keys, mixed $default = null ): iterable | ||
| $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 getRaw( string $key ): mixed | ||
| $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 has( string $key ): boolean | ||
| $key | string | |
public function has(string $key): bool
{
return $this->get($key) !== null;
}
| public set( string $key, mixed $value, Yiisoft\Cache\Ttl|integer|DateInterval|null $ttl = null ): boolean | ||
| $key | string | |
| $value | mixed | |
| $ttl | Yiisoft\Cache\Ttl|integer|DateInterval|null | |
public function set(string $key, mixed $value, Ttl|int|DateInterval|null $ttl = null): bool
{
return $this->handler->set($key, $value, Ttl::from($ttl)->toSeconds());
}
| public setMultiple( iterable $values, Yiisoft\Cache\Ttl|integer|DateInterval|null $ttl = null ): boolean | ||
| $values | iterable | |
| $ttl | Yiisoft\Cache\Ttl|integer|DateInterval|null | |
public function setMultiple(iterable $values, Ttl|int|DateInterval|null $ttl = null): bool
{
return $this->handler->setMultiple($values, Ttl::from($ttl)->toSeconds());
}
Signup or Login in order to comment.