NullBackend.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace Drupal\Core\Cache;
  3. /**
  4. * Defines a stub cache implementation.
  5. *
  6. * The stub implementation is needed when database access is not yet available.
  7. * Because Drupal's caching system never requires that cached data be present,
  8. * these stub functions can short-circuit the process and sidestep the need for
  9. * any persistent storage. Using this cache implementation during normal
  10. * operations would have a negative impact on performance.
  11. *
  12. * This also can be used for testing purposes.
  13. *
  14. * @ingroup cache
  15. */
  16. class NullBackend implements CacheBackendInterface {
  17. /**
  18. * Constructs a NullBackend object.
  19. *
  20. * @param string $bin
  21. * The cache bin for which the object is created.
  22. */
  23. public function __construct($bin) {}
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function get($cid, $allow_invalid = FALSE) {
  28. return FALSE;
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function getMultiple(&$cids, $allow_invalid = FALSE) {
  34. return [];
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) {}
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function setMultiple(array $items = []) {}
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function delete($cid) {}
  48. /**
  49. * {@inheritdoc}
  50. */
  51. public function deleteMultiple(array $cids) {}
  52. /**
  53. * {@inheritdoc}
  54. */
  55. public function deleteAll() {}
  56. /**
  57. * {@inheritdoc}
  58. */
  59. public function invalidate($cid) {}
  60. /**
  61. * {@inheritdoc}
  62. */
  63. public function invalidateMultiple(array $cids) {}
  64. /**
  65. * {@inheritdoc}
  66. */
  67. public function invalidateAll() {}
  68. /**
  69. * {@inheritdoc}
  70. */
  71. public function garbageCollection() {}
  72. /**
  73. * {@inheritdoc}
  74. */
  75. public function removeBin() {}
  76. }