CacheAdapterInterface.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace Guzzle\Cache;
  3. /**
  4. * Interface for cache adapters.
  5. *
  6. * Cache adapters allow Guzzle to utilize various frameworks for caching HTTP responses.
  7. *
  8. * @link http://www.doctrine-project.org/ Inspired by Doctrine 2
  9. */
  10. interface CacheAdapterInterface
  11. {
  12. /**
  13. * Test if an entry exists in the cache.
  14. *
  15. * @param string $id cache id The cache id of the entry to check for.
  16. * @param array $options Array of cache adapter options
  17. *
  18. * @return bool Returns TRUE if a cache entry exists for the given cache id, FALSE otherwise.
  19. */
  20. public function contains($id, array $options = null);
  21. /**
  22. * Deletes a cache entry.
  23. *
  24. * @param string $id cache id
  25. * @param array $options Array of cache adapter options
  26. *
  27. * @return bool TRUE on success, FALSE on failure
  28. */
  29. public function delete($id, array $options = null);
  30. /**
  31. * Fetches an entry from the cache.
  32. *
  33. * @param string $id cache id The id of the cache entry to fetch.
  34. * @param array $options Array of cache adapter options
  35. *
  36. * @return string The cached data or FALSE, if no cache entry exists for the given id.
  37. */
  38. public function fetch($id, array $options = null);
  39. /**
  40. * Puts data into the cache.
  41. *
  42. * @param string $id The cache id
  43. * @param string $data The cache entry/data
  44. * @param int|bool $lifeTime The lifetime. If != false, sets a specific lifetime for this cache entry
  45. * @param array $options Array of cache adapter options
  46. *
  47. * @return bool TRUE if the entry was successfully stored in the cache, FALSE otherwise.
  48. */
  49. public function save($id, $data, $lifeTime = false, array $options = null);
  50. }