1: <?php
2:
3: namespace Guzzle\Cache;
4:
5: use Zend\Cache\Storage\StorageInterface;
6:
7: /**
8: * Zend Framework 2 cache adapter
9: *
10: * @link http://packages.zendframework.com/docs/latest/manual/en/zend.cache.html
11: */
12: class Zf2CacheAdapter extends AbstractCacheAdapter
13: {
14: /**
15: * @param StorageInterface $cache Zend Framework 2 cache adapter
16: */
17: public function __construct(StorageInterface $cache)
18: {
19: $this->cache = $cache;
20: }
21:
22: /**
23: * {@inheritdoc}
24: */
25: public function contains($id, array $options = null)
26: {
27: return $this->cache->hasItem($id);
28: }
29:
30: /**
31: * {@inheritdoc}
32: */
33: public function delete($id, array $options = null)
34: {
35: return $this->cache->removeItem($id);
36: }
37:
38: /**
39: * {@inheritdoc}
40: */
41: public function fetch($id, array $options = null)
42: {
43: return $this->cache->getItem($id);
44: }
45:
46: /**
47: * {@inheritdoc}
48: */
49: public function save($id, $data, $lifeTime = false, array $options = null)
50: {
51: return $this->cache->setItem($id, $data);
52: }
53: }
54: