0 follower

Final Class Yiisoft\Cache\DependencyAwareCache

InheritanceYiisoft\Cache\DependencyAwareCache
ImplementsPsr\SimpleCache\CacheInterface

Cache provides support for the data caching, including dependencies.

The actual data caching is performed via {@see \Yiisoft\Cache\DependencyAwareCache::handler()}.

Method Details

Hide inherited methods

__construct() public method

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
) {
}

            
clear() public method

public boolean clear ( )

                public function clear(): bool
{
    return $this->handler->clear();
}

            
delete() public method

public boolean delete ( mixed $key )
$key mixed

                public function delete($key): bool
{
    return $this->handler->delete($key);
}

            
deleteMultiple() public method

public boolean deleteMultiple ( mixed $keys )
$keys mixed

                public function deleteMultiple($keys): bool
{
    return $this->handler->deleteMultiple($keys);
}

            
get() public method

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);
}

            
getMultiple() public method

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;
}

            
getRaw() public method

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);
}

            
has() public method

public boolean has ( string $key )
$key string

                public function has(string $key): bool
{
    return $this->get($key) !== null;
}

            
set() public method

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());
}

            
setMultiple() public method

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());
}