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 \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 delete( mixed $key ): boolean | ||
| $key | mixed | |
public function delete($key): bool
{
$this->validateKey($key);
return wincache_ucache_delete($key);
}
| 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;
}
| 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;
}
| 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;
}
| public has( mixed $key ): boolean | ||
| $key | mixed | |
public function has($key): bool
{
$this->validateKey($key);
return wincache_ucache_exists($key);
}
| 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);
}
| 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) === [];
}
Signup or Login in order to comment.