Patched to Drupal 8.4.8 level. See https://www.drupal.org/sa-core-2018-004 and patch...
[yaffs-website] / web / core / lib / Drupal / Core / KeyValueStore / KeyValueStoreInterface.php
1 <?php
2
3 namespace Drupal\Core\KeyValueStore;
4
5 /**
6  * Defines the interface for key/value store implementations.
7  */
8 interface KeyValueStoreInterface {
9
10   /**
11    * Returns the name of this collection.
12    *
13    * @return string
14    *   The name of this collection.
15    */
16   public function getCollectionName();
17
18   /**
19    * Returns whether a given key exists in the store.
20    *
21    * @param string $key
22    *   The key to check.
23    *
24    * @return bool
25    *   TRUE if the key exists, FALSE otherwise.
26    */
27   public function has($key);
28
29   /**
30    * Returns the stored value for a given key.
31    *
32    * @param string $key
33    *   The key of the data to retrieve.
34    * @param mixed $default
35    *   The default value to use if the key is not found.
36    *
37    * @return mixed
38    *   The stored value, or the default value if no value exists.
39    */
40   public function get($key, $default = NULL);
41
42   /**
43    * Returns the stored key/value pairs for a given set of keys.
44    *
45    * @param array $keys
46    *   A list of keys to retrieve.
47    *
48    * @return array
49    *   An associative array of items successfully returned, indexed by key.
50    *
51    * @todo What's returned for non-existing keys?
52    */
53   public function getMultiple(array $keys);
54
55   /**
56    * Returns all stored key/value pairs in the collection.
57    *
58    * @return array
59    *   An associative array containing all stored items in the collection.
60    */
61   public function getAll();
62
63   /**
64    * Saves a value for a given key.
65    *
66    * @param string $key
67    *   The key of the data to store.
68    * @param mixed $value
69    *   The data to store.
70    */
71   public function set($key, $value);
72
73   /**
74    * Saves a value for a given key if it does not exist yet.
75    *
76    * @param string $key
77    *   The key of the data to store.
78    * @param mixed $value
79    *   The data to store.
80    *
81    * @return bool
82    *   TRUE if the data was set, FALSE if it already existed.
83    */
84   public function setIfNotExists($key, $value);
85
86   /**
87    * Saves key/value pairs.
88    *
89    * @param array $data
90    *   An associative array of key/value pairs.
91    */
92   public function setMultiple(array $data);
93
94   /**
95    * Renames a key.
96    *
97    * @param string $key
98    *   The key to rename.
99    * @param string $new_key
100    *   The new key name.
101    */
102   public function rename($key, $new_key);
103
104   /**
105    * Deletes an item from the key/value store.
106    *
107    * @param string $key
108    *   The item name to delete.
109    */
110   public function delete($key);
111
112   /**
113    * Deletes multiple items from the key/value store.
114    *
115    * @param array $keys
116    *   A list of item names to delete.
117    */
118   public function deleteMultiple(array $keys);
119
120   /**
121    * Deletes all items from the key/value store.
122    */
123   public function deleteAll();
124
125 }