CacheInterface.php

  1. 8.0.x lib/Drush/Cache/CacheInterface.php
  2. 7.x lib/Drush/Cache/CacheInterface.php
  3. master lib/Drush/Cache/CacheInterface.php

Definition of Drush\Cache\CacheInterface.

Namespace

Drush\Cache

Interfaces

Namesort descending Description
CacheInterface Interface for cache implementations.

File

lib/Drush/Cache/CacheInterface.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of Drush\Cache\CacheInterface.
  5. */
  6. namespace Drush\Cache;
  7. /**
  8. * Interface for cache implementations.
  9. *
  10. * All cache implementations have to implement this interface.
  11. * JSONCache provides the default implementation, which can be
  12. * consulted as an example.
  13. *
  14. * To make Drush use your implementation for a certain cache bin, you have to
  15. * set a variable with the name of the cache bin as its key and the name of
  16. * your class as its value. For example, if your implementation of
  17. * CacheInterface was called MyCustomCache, the following line in
  18. * drushrc.php would make Drush use it for the 'example' bin:
  19. * @code
  20. * $options['cache-class-example'] = 'MyCustomCache;
  21. * @endcode
  22. *
  23. * Additionally, you can register your cache implementation to be used by
  24. * default for all cache bins by setting the option 'cache-default-class' to
  25. * the name of your implementation of the CacheInterface, e.g.
  26. * @code
  27. * $options['cache-default-class'] = 'MyCustomCache;
  28. * @endcode
  29. *
  30. * @see _drush_cache_get_object()
  31. * @see \Drupal\Core\Cache\CacheBackendInterface
  32. */
  33. interface CacheInterface {
  34. /**
  35. * Constructor.
  36. *
  37. * @param $bin
  38. * The cache bin for which the object is created.
  39. */
  40. function __construct($bin);
  41. /**
  42. * Return data from the persistent cache.
  43. *
  44. * @param string $cid
  45. * The cache ID of the data to retrieve.
  46. *
  47. * @return
  48. * The cache or FALSE on failure.
  49. */
  50. function get($cid);
  51. /**
  52. * Return data from the persistent cache when given an array of cache IDs.
  53. *
  54. * @param array $cids
  55. * An array of cache IDs for the data to retrieve. This is passed by
  56. * reference, and will have the IDs successfully returned from cache
  57. * removed.
  58. *
  59. * @return
  60. * An array of the items successfully returned from cache indexed by cid.
  61. */
  62. function getMultiple(&$cids);
  63. /**
  64. * Store data in the persistent cache.
  65. *
  66. * @param string $cid
  67. * The cache ID of the data to store.
  68. * @param array $data
  69. * The data to store in the cache.
  70. * @param $expire
  71. * One of the following values:
  72. * - DRUSH_CACHE_PERMANENT: Indicates that the item should never be removed unless
  73. * explicitly told to using _drush_cache_clear_all() with a cache ID.
  74. * - DRUSH_CACHE_TEMPORARY: Indicates that the item should be removed at the next
  75. * general cache wipe.
  76. * - A Unix timestamp: Indicates that the item should be kept at least until
  77. * the given time, after which it behaves like CACHE_TEMPORARY.
  78. */
  79. function set($cid, $data, $expire = DRUSH_CACHE_PERMANENT);
  80. /**
  81. * Expire data from the cache. If called without arguments, expirable
  82. * entries will be cleared from all known cache bins.
  83. *
  84. * @param string $cid
  85. * If set, the cache ID to delete. Otherwise, all cache entries that can
  86. * expire are deleted.
  87. * @param bool $wildcard
  88. * If set to TRUE, the $cid is treated as a substring
  89. * to match rather than a complete ID. The match is a right hand
  90. * match. If '*' is given as $cid, the bin $bin will be emptied.
  91. */
  92. function clear($cid = NULL, $wildcard = FALSE);
  93. /**
  94. * Check if a cache bin is empty.
  95. *
  96. * A cache bin is considered empty if it does not contain any valid data for
  97. * any cache ID.
  98. *
  99. * @return
  100. * TRUE if the cache bin specified is empty.
  101. */
  102. function isEmpty();
  103. }