Zf2CacheAdapter.php 919 B

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