0 follower

Final Class Yiisoft\Cache\WinCache\WinCache

InheritanceYiisoft\Cache\WinCache\WinCache
ImplementsPsr\SimpleCache\CacheInterface

WinCache provides Windows Cache caching in terms of an application component.

To use this application component, the WinCache PHP extension must be loaded. Also note that "wincache.ucenabled" should be set to "1" in your php.ini file.

See \Psr\SimpleCache\CacheInterface for common cache operations that are supported by WinCache.

Constants

Hide inherited constants

Constant Value Description Defined By
TTL_EXPIRED -1 Yiisoft\Cache\WinCache\WinCache
TTL_INFINITY 0 Yiisoft\Cache\WinCache\WinCache

Method Details

Hide inherited methods

clear() public method

public clear( ): boolean

                public function clear(): bool
{
    return wincache_ucache_clear();
}

            
delete() public method

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

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

            
deleteMultiple() public method

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

                public function deleteMultiple($keys): bool
{
    $keys = $this->iterableToArray($keys);
    $this->validateKeys($keys);
    $deleted = wincache_ucache_delete($keys);
    if (!is_array($deleted)) {
        return false;
    }
    $deleted = array_flip($deleted);
    foreach ($keys as $expectedKey) {
        if (!isset($deleted[$expectedKey])) {
            return false;
        }
    }
    return true;
}

            
get() public method

public get( mixed $key, mixed $default null ): mixed
$key mixed
$default mixed

                public function get($key, $default = null)
{
    $this->validateKey($key);
    $value = wincache_ucache_get($key, $success);
    return $success ? $value : $default;
}

            
getMultiple() public method

public getMultiple( mixed $keys, mixed $default null ): iterable
$keys mixed
$default mixed

                public function getMultiple($keys, $default = null): iterable
{
    $keys = $this->iterableToArray($keys);
    $this->validateKeys($keys);
    $valuesFromCache = $this->normalizeWinCacheOutput(wincache_ucache_get($keys));
    $values = array_fill_keys($keys, $default);
    foreach ($values as $key => $value) {
        $values[$key] = $valuesFromCache[$key] ?? $value;
    }
    return $values;
}

            
has() public method

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

                public function has($key): bool
{
    $this->validateKey($key);
    return wincache_ucache_exists($key);
}

            
set() public method

public set( mixed $key, mixed $value, mixed $ttl null ): boolean
$key mixed
$value mixed
$ttl mixed

                public function set($key, $value, $ttl = null): bool
{
    $this->validateKey($key);
    $ttl = $this->normalizeTtl($ttl);
    if ($ttl <= self::TTL_EXPIRED) {
        return $this->delete($key);
    }
    return wincache_ucache_set($key, $value, $ttl);
}

            
setMultiple() public method

public setMultiple( mixed $values, mixed $ttl null ): boolean
$values mixed
$ttl mixed

                public function setMultiple($values, $ttl = null): bool
{
    $values = $this->iterableToArray($values);
    $this->validateKeysOfValues($values);
    $ttl = $this->normalizeTtl($ttl);
    return wincache_ucache_set($values, null, $ttl) === [];
}