<?php
namespace M6Web\Bundle\ApcuBundle\CacheAdapters;

use M6Web\Bundle\GuzzleHttpBundle\Cache\CacheInterface;
use M6Web\Bundle\ApcuBundle\Apcu\Apcu as BaseApcu;

/**
 * Cache interface for the m6web guzzlehttp bundle
 */
class M6WebGuzzleHttp extends BaseApcu implements CacheInterface
{
    /**
     * {@inheritDoc}
     */
    public function has($key)
    {
        return $this->exists($key);
    }

    /**
     * {@inheritDoc}
     */
    public function get($key)
    {
        return $this->fetch($key);
    }

    /**
     * {@inheritDoc}
     */
    public function set($key, $value, $ttl = null)
    {
        return $this->store($key, $value, $ttl);
    }

    /**
     * {@inheritDoc}
     */
    public function remove($key)
    {
        return $this->delete($key);
    }

    /**
     * {@inheritDoc}
     */
    public function ttl($key)
    {
        $key   = $this->getFinalKey($key);
        $infos = apcu_cache_info();

        foreach ($infos['cache_list'] as $entry) {
            if ($entry['info'] == $key) {
                return $entry['ttl'];
            }
        }

        return false;
    }
}
Add M6Web Guzzlehttp cache interface
Add M6Web Guzzlehttp cache interface
