Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 7
ApcuCache
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 6
72
0.00% covered (danger)
0.00%
0 / 7
 get
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 set
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 destroy
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 has
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 ttl
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 clear
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
<?php
declare(strict_types=1);
namespace Eywa\Cache {
    class ApcuCache implements CacheInterface
    {
        /**
         * @inheritDoc
         */
        public function get(string $key)
        {
            return $this->has($key) ? apcu_fetch($key) : false;
        }
        /**
         * @inheritDoc
         */
        public function set(string $key, $value): CacheInterface
        {
            apcu_add($key, $value, $this->ttl());
            return  $this;
        }
        /**
         * @inheritDoc
         */
        public function destroy(string $key): bool
        {
            return $this->has($key) ? apcu_delete($key) : false;
        }
        /**
         * @inheritDoc
         */
        public function has(string $key): bool
        {
            return  apcu_exists($key);
        }
        /**
         * @inheritDoc
         */
        public function ttl(): int
        {
            return  intval(env('CACHE_TTL', CACHE_DEFAULT_TTL));
        }
        /**
         * @inheritDoc
         */
        public function clear(): bool
        {
            return  apcu_clear_cache();
        }
    }
}