3 namespace Drupal\Core\Cache;
6 * Provides checksums for cache tag invalidations.
8 * Cache backends can use this to check if any cache tag invalidations happened
9 * for a stored cache item.
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.
19 interface CacheTagsChecksumInterface {
22 * Returns the sum total of validations for a given set of tags.
24 * Called by a backend when storing a cache item.
26 * @param string[] $tags
27 * Array of cache tags.
30 * Cache tag invalidations checksum.
32 public function getCurrentChecksum(array $tags);
35 * Returns whether the checksum is valid for the given cache tags.
37 * Used when retrieving a cache item in a cache backend, to verify that no
38 * cache tag based invalidation happened.
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.
46 * FALSE if cache tag invalidations happened for the passed in tags since
47 * the cache item was stored, TRUE otherwise.
49 public function isValid($checksum, array $tags);
52 * Reset statically cached tags.
54 * This is only used by tests.
56 public function reset();