1
0

downgrade to kirby v3

This commit is contained in:
Philip Wagner
2024-09-01 10:47:15 +02:00
parent a4b2aece7b
commit af86acb7a1
1085 changed files with 54743 additions and 65042 deletions

View File

@@ -16,14 +16,10 @@ use Memcached as MemcachedExt;
class MemCached extends Cache
{
/**
* Store for the memcache connection
* store for the memcache connection
* @var \Memcached
*/
protected MemcachedExt $connection;
/**
* Stores whether the connection was successful
*/
protected bool $enabled;
protected $connection;
/**
* Sets all parameters which are needed to connect to Memcached
@@ -43,19 +39,7 @@ class MemCached extends Cache
parent::__construct(array_merge($defaults, $options));
$this->connection = new MemcachedExt();
$this->enabled = $this->connection->addServer(
$this->options['host'],
$this->options['port']
);
}
/**
* Returns whether the cache is ready to
* store values
*/
public function enabled(): bool
{
return $this->enabled;
$this->connection->addServer($this->options['host'], $this->options['port']);
}
/**
@@ -66,28 +50,35 @@ class MemCached 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
{
$key = $this->key($key);
$value = (new Value($value, $minutes))->toJson();
$expires = $this->expiration($minutes);
return $this->connection->set($key, $value, $expires);
return $this->connection->set($this->key($key), (new Value($value, $minutes))->toJson(), $this->expiration($minutes));
}
/**
* 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): Value|null
public function retrieve(string $key)
{
$value = $this->connection->get($this->key($key));
return Value::fromJson($value);
return Value::fromJson($this->connection->get($this->key($key)));
}
/**
* Removes an item from the cache and returns
* whether the operation was successful
*
* @param string $key
* @return bool
*/
public function remove(string $key): bool
{
@@ -98,6 +89,8 @@ class MemCached extends Cache
* Flushes the entire cache and returns
* whether the operation was successful;
* WARNING: Memcached only supports flushing the whole cache at once!
*
* @return bool
*/
public function flush(): bool
{