3 namespace Drupal\Core\Cache;
6 * Provides a caching wrapper to be used in place of large structures.
8 * This should be extended by systems that need to cache large amounts of data
9 * to calling functions. These structures can become very large, so this
10 * class is used to allow different strategies to be used for caching internally
11 * (lazy loading, building caches over time etc.). This can dramatically reduce
12 * the amount of data that needs to be loaded from cache backends on each
13 * request, and memory usage from static caches of that same data.
15 * The default implementation is \Drupal\Core\Cache\CacheCollector.
19 interface CacheCollectorInterface {
22 * Gets value from the cache.
25 * Key that identifies the data.
28 * The corresponding cache data.
30 public function get($key);
35 * It depends on the specific case and implementation whether this has a
36 * permanent effect or if it just affects the current request.
39 * Key that identifies the data.
43 public function set($key, $value);
46 * Deletes the element.
48 * It depends on the specific case and implementation whether this has a
49 * permanent effect or if it just affects the current request.
52 * Key that identifies the data.
54 public function delete($key);
57 * Returns whether data exists for this key.
60 * Key that identifies the data.
62 public function has($key);
65 * Resets the local cache.
67 * Does not clear the persistent cache.
69 public function reset();
72 * Clears the collected cache entry.
74 public function clear();