Final Class Yiisoft\Cache\WinCache\WinCache
| Inheritance | Yiisoft\Cache\WinCache\WinCache |
|---|---|
| Implements | Psr\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.
Public Methods
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| TTL_EXPIRED | -1 | Yiisoft\Cache\WinCache\WinCache | |
| TTL_INFINITY | 0 | Yiisoft\Cache\WinCache\WinCache |
Method Details
| public boolean delete ( mixed $key ) | ||
| $key | mixed | |
public function delete($key): bool
{
$this->validateKey($key);
return wincache_ucache_delete($key);
}
| 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;
}
| 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;
}
| 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;
}
| public boolean has ( mixed $key ) | ||
| $key | mixed | |
public function has($key): bool
{
$this->validateKey($key);
return wincache_ucache_exists($key);
}
| 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);
}
| 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) === [];
}
Signup or Login in order to comment.