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 \Yiisoft\Cache\DependencyAwareCache::handler().

Method Details

Hide inherited methods

__construct() public method

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

            
clear() public method

public clear( ): boolean

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

            
delete() public method

public delete( mixed $key ): boolean
$key mixed

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

            
deleteMultiple() public method

public deleteMultiple( mixed $keys ): boolean
$keys mixed

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

            
get() public method

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

            
getMultiple() public method

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

            
getRaw() public method

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

            
has() public method

public has( string $key ): boolean
$key string

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

            
set() public method

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

            
setMultiple() public method

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