Add missing methods to apcu driver

This commit is contained in:
Timothy Warren 2017-01-17 11:28:13 -05:00
parent 876858b515
commit d52eb9c380
2 changed files with 57 additions and 10 deletions

28
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,28 @@
# Composer stores all downloaded packages in the vendor/ directory.
# Do not use the following if the vendor/ directory is commited to
# your git repository.
cache:
paths:
- vendor/
services:
- memcached:latest
- redis:latest
test:7:
before_script:
- bash build/docker_install.sh > /dev/null
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install --no-dev
image: php:7
script:
- phpunit -c build
test:7.1:
before_script:
- bash build/docker_install.sh > /dev/null
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install --no-dev
image: php:7.1
script:
- phpunit -c build

View File

@ -23,6 +23,25 @@ use Aviat\Banker\Exception\CacheException;
* Memcached cache backend
*/
class ApcuDriver extends AbstractDriver {
/**
* Constructor
*
* @param array $config - Not used by this driver
* @param array $options - Not used by this driver
*/
public function __construct(array $config = [], array $options = [])
{
}
/**
* Destructor
*/
public function __destruct()
{
}
/**
* See if a key currently exists in the cache
@ -32,7 +51,7 @@ class ApcuDriver extends AbstractDriver {
*/
public function exists(string $key): bool
{
return apcu_exists($key) !== FALSE;
return \apcu_exists($key) !== FALSE;
}
/**
@ -43,7 +62,7 @@ class ApcuDriver extends AbstractDriver {
*/
public function get(string $key)
{
return apcu_fetch($key);
return \apcu_fetch($key);
}
/**
@ -54,7 +73,7 @@ class ApcuDriver extends AbstractDriver {
*/
public function getMultiple(array $keys = []): array
{
return apcu_fetch($keys);
return \apcu_fetch($keys);
}
/**
@ -67,13 +86,13 @@ class ApcuDriver extends AbstractDriver {
*/
public function set(string $key, $value, int $expires = 0): DriverInterface
{
if ( ! apcu_exists($key))
if ( ! \apcu_exists($key))
{
apcu_add($key, $value, $expires);
\apcu_add($key, $value, $expires);
}
else
{
apcu_store($key, $value, $expires);
\apcu_store($key, $value, $expires);
}
return $this;
@ -87,7 +106,7 @@ class ApcuDriver extends AbstractDriver {
*/
public function delete(string $key): bool
{
return apcu_delete($key);
return \apcu_delete($key);
}
/**
@ -98,7 +117,7 @@ class ApcuDriver extends AbstractDriver {
*/
public function deleteMultiple(array $keys = []): bool
{
return apcu_delete($keys);
return \apcu_delete($keys);
}
/**
@ -108,7 +127,7 @@ class ApcuDriver extends AbstractDriver {
*/
public function flush(): bool
{
return apcu_clear_cache();
return \apcu_clear_cache();
}
/**
@ -123,7 +142,7 @@ class ApcuDriver extends AbstractDriver {
if ($this->exists($key))
{
$value = $this->get($key);
return apcu_store($key, $value, $expires);
return \apcu_store($key, $value, $expires);
}
$this->getLogger()->warn("Tried to set expiration on a key that does not exist");