\Drupflare\Anachron\Drupal\Cache LegacyCacheCollector

Collects the cache metadata of everything legacy code reads during a request.

Drupal 7 modules have no cache tags, so a page they build would carry none. The shims for the cache, variable, entity and database APIs write here, and the response takes the result. Tags only narrow invalidation: a read that cannot be tagged adds the broad tag or max-age 0, and contexts are only ever added.

Summary

Methods
Properties
Constants
current
tag
read
context
broad
noCache
invalidate
metadata
reset
No public properties found
BROAD
TEMPORARY
No protected methods found
No protected properties found
No protected constants found
No private methods found
tags
maxAge
contexts
No private constants found

Constant

BROAD

BROAD = 'legacy:all'

TEMPORARY

TEMPORARY = 'legacy:cache:temporary'

Properties

$tags

$tags : array

The tags read so far, as keys.

Type

array<string, true> —

$maxAge

$maxAge : int

The lowest max-age any access asked for.

Type

int

$contexts

$contexts : array

The value kept for this request.

Type

array<string, true> —

Methods

current()

current() : ?self

The collector of the running request, or null before the container exists.

Returns

?self —

tag()

tag(string  $prefix, string  $name) : string

Makes a string safe for a header and bounded in length, which tags travel in.

Parameters

string $prefix
string $name

Returns

string —

read()

read(list  $tags) : void

Adds the tags of something legacy code read.

Parameters

list $tags

The tags.

Returns

void —

context()

context(string  ...$contexts) : void

Adds cache contexts the output depends on.

Parameters

string $contexts variadic

Returns

void —

broad()

broad(string  $reason) : void

Adds the broad tag, for an access that cannot be tagged.

Parameters

string $reason

Returns

void —

noCache()

noCache(string  $reason) : void

Makes the response uncacheable, for an access that cannot be tagged.

Parameters

string $reason

Returns

void —

invalidate()

invalidate(list  $tags) : void

Invalidates tags a legacy write affects, and the broad tag with them.

Parameters

list $tags

The tags.

Returns

void —

metadata()

metadata() : \Drupal\Core\Cache\CacheableMetadata

Returns what was collected as cache metadata.

Returns

\Drupal\Core\Cache\CacheableMetadata —

reset()

reset() : void

Forgets what was collected.

Returns

void —