NullStorageExpirable.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. namespace Drupal\Core\KeyValueStore;
  3. /**
  4. * Defines a null key/value store implementation.
  5. */
  6. class NullStorageExpirable implements KeyValueStoreExpirableInterface {
  7. /**
  8. * The actual storage of key-value pairs.
  9. *
  10. * @var array
  11. */
  12. protected $data = [];
  13. /**
  14. * The name of the collection holding key and value pairs.
  15. *
  16. * @var string
  17. */
  18. protected $collection;
  19. /**
  20. * Creates a new expirable null key/value store.
  21. */
  22. public function __construct($collection) {
  23. $this->collection = $collection;
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function has($key) {
  29. return FALSE;
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function get($key, $default = NULL) {
  35. return NULL;
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function getMultiple(array $keys) {
  41. return [];
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function getAll() {
  47. return [];
  48. }
  49. /**
  50. * {@inheritdoc}
  51. */
  52. public function set($key, $value) {}
  53. /**
  54. * {@inheritdoc}
  55. */
  56. public function setIfNotExists($key, $value) {}
  57. /**
  58. * {@inheritdoc}
  59. */
  60. public function setMultiple(array $data) {}
  61. /**
  62. * {@inheritdoc}
  63. */
  64. public function rename($key, $new_key) {
  65. }
  66. /**
  67. * {@inheritdoc}
  68. */
  69. public function delete($key) {}
  70. /**
  71. * {@inheritdoc}
  72. */
  73. public function deleteMultiple(array $keys) {}
  74. /**
  75. * {@inheritdoc}
  76. */
  77. public function deleteAll() {}
  78. /**
  79. * {@inheritdoc}
  80. */
  81. public function getCollectionName() {
  82. return $this->collection;
  83. }
  84. /**
  85. * {@inheritdoc}
  86. */
  87. public function setMultipleWithExpire(array $data, $expire) {}
  88. /**
  89. * {@inheritdoc}
  90. */
  91. public function setWithExpire($key, $value, $expire) {}
  92. /**
  93. * {@inheritdoc}
  94. */
  95. public function setWithExpireIfNotExists($key, $value, $expire) {}
  96. }