CacheCollectorInterface.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace Drupal\Core\Cache;
  3. /**
  4. * Provides a caching wrapper to be used in place of large structures.
  5. *
  6. * This should be extended by systems that need to cache large amounts of data
  7. * to calling functions. These structures can become very large, so this
  8. * class is used to allow different strategies to be used for caching internally
  9. * (lazy loading, building caches over time etc.). This can dramatically reduce
  10. * the amount of data that needs to be loaded from cache backends on each
  11. * request, and memory usage from static caches of that same data.
  12. *
  13. * The default implementation is \Drupal\Core\Cache\CacheCollector.
  14. *
  15. * @ingroup cache
  16. */
  17. interface CacheCollectorInterface {
  18. /**
  19. * Gets value from the cache.
  20. *
  21. * @param string $key
  22. * Key that identifies the data.
  23. *
  24. * @return mixed
  25. * The corresponding cache data.
  26. */
  27. public function get($key);
  28. /**
  29. * Sets cache data.
  30. *
  31. * It depends on the specific case and implementation whether this has a
  32. * permanent effect or if it just affects the current request.
  33. *
  34. * @param string $key
  35. * Key that identifies the data.
  36. * @param mixed $value
  37. * The data to be set.
  38. */
  39. public function set($key, $value);
  40. /**
  41. * Deletes the element.
  42. *
  43. * It depends on the specific case and implementation whether this has a
  44. * permanent effect or if it just affects the current request.
  45. *
  46. * @param string $key
  47. * Key that identifies the data.
  48. */
  49. public function delete($key);
  50. /**
  51. * Returns whether data exists for this key.
  52. *
  53. * @param string $key
  54. * Key that identifies the data.
  55. */
  56. public function has($key);
  57. /**
  58. * Resets the local cache.
  59. *
  60. * Does not clear the persistent cache.
  61. */
  62. public function reset();
  63. /**
  64. * Clears the collected cache entry.
  65. */
  66. public function clear();
  67. }