Update Composer packages

This commit is contained in:
Paul Nicoué 2022-12-19 14:56:05 +01:00
parent 0320235f6c
commit a8b68fb61b
378 changed files with 28466 additions and 28852 deletions

View file

@ -15,11 +15,17 @@ use APCUIterator;
*/
class ApcuCache extends Cache
{
/**
* Returns whether the cache is ready to
* store values
*/
public function enabled(): bool
{
return apcu_enabled();
}
/**
* Determines if an item exists in the cache
*
* @param string $key
* @return bool
*/
public function exists(string $key): bool
{
@ -29,24 +35,19 @@ class ApcuCache extends Cache
/**
* Flushes the entire cache and returns
* whether the operation was successful
*
* @return bool
*/
public function flush(): bool
{
if (empty($this->options['prefix']) === false) {
return apcu_delete(new APCUIterator('!^' . preg_quote($this->options['prefix']) . '!'));
} else {
return apcu_clear_cache();
}
return apcu_clear_cache();
}
/**
* Removes an item from the cache and returns
* whether the operation was successful
*
* @param string $key
* @return bool
*/
public function remove(string $key): bool
{
@ -56,13 +57,11 @@ class ApcuCache extends Cache
/**
* Internal method to retrieve the raw cache value;
* needs to return a Value object or null if not found
*
* @param string $key
* @return \Kirby\Cache\Value|null
*/
public function retrieve(string $key)
public function retrieve(string $key): Value|null
{
return Value::fromJson(apcu_fetch($this->key($key)));
$value = apcu_fetch($this->key($key));
return Value::fromJson($value);
}
/**
@ -73,14 +72,12 @@ class ApcuCache extends Cache
* // put an item in the cache for 15 minutes
* $cache->set('value', 'my value', 15);
* </code>
*
* @param string $key
* @param mixed $value
* @param int $minutes
* @return bool
*/
public function set(string $key, $value, int $minutes = 0): bool
{
return apcu_store($this->key($key), (new Value($value, $minutes))->toJson(), $this->expiration($minutes));
$key = $this->key($key);
$value = (new Value($value, $minutes))->toJson();
$expires = $this->expiration($minutes);
return apcu_store($key, $value, $expires);
}
}