Upgraded drupal core with security updates
[yaffs-website] / web / core / lib / Drupal / Core / Cache / CacheTagsChecksumInterface.php
1 <?php
2
3 namespace Drupal\Core\Cache;
4
5 /**
6  * Provides checksums for cache tag invalidations.
7  *
8  * Cache backends can use this to check if any cache tag invalidations happened
9  * for a stored cache item.
10  *
11  * To do so, they can inject the cache_tags.invalidator.checksum service, and
12  * when a cache item is written, store cache tags together with the current
13  * checksum, calculated by getCurrentChecksum(). When a cache item is fetched,
14  * the checksum can be validated with isValid(). The service will return FALSE
15  * if any of those cache tags were invalidated in the meantime.
16  *
17  * @ingroup cache
18  */
19 interface CacheTagsChecksumInterface {
20
21   /**
22    * Returns the sum total of validations for a given set of tags.
23    *
24    * Called by a backend when storing a cache item.
25    *
26    * @param string[] $tags
27    *   Array of cache tags.
28    *
29    * @return string
30    *   Cache tag invalidations checksum.
31    */
32   public function getCurrentChecksum(array $tags);
33
34   /**
35    * Returns whether the checksum is valid for the given cache tags.
36    *
37    * Used when retrieving a cache item in a cache backend, to verify that no
38    * cache tag based invalidation happened.
39    *
40    * @param int $checksum
41    *   The checksum that was stored together with the cache item.
42    * @param string[] $tags
43    *   The cache tags that were stored together with the cache item.
44    *
45    * @return bool
46    *   FALSE if cache tag invalidations happened for the passed in tags since
47    *   the cache item was stored, TRUE otherwise.
48    */
49   public function isValid($checksum, array $tags);
50
51   /**
52    * Reset statically cached tags.
53    *
54    * This is only used by tests.
55    */
56   public function reset();
57
58 }