Version 1
[yaffs-website] / web / core / lib / Drupal / Core / State / StateInterface.php
1 <?php
2
3 namespace Drupal\Core\State;
4
5 /**
6  * Defines the interface for the state system.
7  *
8  * @ingroup state_api
9  */
10 interface StateInterface {
11
12   /**
13    * Returns the stored value for a given key.
14    *
15    * @param string $key
16    *   The key of the data to retrieve.
17    * @param mixed $default
18    *   The default value to use if the key is not found.
19    *
20    * @return mixed
21    *   The stored value, or NULL if no value exists.
22    */
23   public function get($key, $default = NULL);
24
25   /**
26    * Returns the stored key/value pairs for a given set of keys.
27    *
28    * @param array $keys
29    *   A list of keys to retrieve.
30    *
31    * @return array
32    *   An associative array of items successfully returned, indexed by key.
33    */
34   public function getMultiple(array $keys);
35
36   /**
37    * Saves a value for a given key.
38    *
39    * @param string $key
40    *   The key of the data to store.
41    * @param mixed $value
42    *   The data to store.
43    */
44   public function set($key, $value);
45
46   /**
47    * Saves key/value pairs.
48    *
49    * @param array $data
50    *   An associative array of key/value pairs.
51    */
52   public function setMultiple(array $data);
53
54   /**
55    * Deletes an item.
56    *
57    * @param string $key
58    *   The item name to delete.
59    */
60   public function delete($key);
61
62   /**
63    * Deletes multiple items.
64    *
65    * @param array $keys
66    *   A list of item names to delete.
67    */
68   public function deleteMultiple(array $keys);
69
70   /**
71    * Resets the static cache.
72    *
73    * This is mainly used in testing environments.
74    */
75   public function resetCache();
76
77 }