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 {@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 boolean clear ( )

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

            
delete() public method

public boolean delete ( mixed $key )
$key mixed

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

            
deleteMultiple() public method

public boolean deleteMultiple ( mixed $keys )
$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 mixed get ( mixed $key, mixed $default null )
$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 iterable getMultiple ( mixed $keys, mixed $default null )
$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 boolean has ( mixed $key )
$key mixed

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

            
set() public method

public boolean set ( mixed $key, mixed $value, mixed $ttl null )
$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 boolean setMultiple ( mixed $values, mixed $ttl null )
$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) === [];
}