class TestDiscoveryCacheContext implements CacheContextInterface (View source)

Defines the TestDiscoveryCacheContext service.

Cache context ID: 'test_discovery'.

Properties

protected TestDiscovery $testDiscovery

The test discovery service.

protected PrivateKey $privateKey

The private key service.

protected string $hash

The hash of discovered test information.

Methods

__construct(TestDiscovery $test_discovery, PrivateKey $private_key)

Construct a test discovery cache context.

static string
getLabel()

Returns the label of the cache context.

string
getContext()

Returns the string representation of the cache context.

getCacheableMetadata()

Gets the cacheability metadata for the context.

string
hash(string $identifier)

Hashes the given string.

Details

__construct(TestDiscovery $test_discovery, PrivateKey $private_key)

Construct a test discovery cache context.

Parameters

TestDiscovery $test_discovery

The test discovery service.

PrivateKey $private_key

The private key service.

static string getLabel()

Returns the label of the cache context.

Return Value

string

The label of the cache context.

string getContext()

Returns the string representation of the cache context.

A cache context service's name is used as a token (placeholder) cache key, and is then replaced with the string returned by this method.

Return Value

string

The string representation of the cache context.

CacheableMetadata getCacheableMetadata()

Gets the cacheability metadata for the context.

There are three valid cases for the returned CacheableMetadata object:

  • An empty object means this can be optimized away safely.
  • A max-age of 0 means that this context can never be optimized away. It will never bubble up and cache tags will not be used.
  • Any non-zero max-age and cache tags will bubble up into the cache item if this is optimized away to allow for invalidation if the context value changes.

Return Value

CacheableMetadata

A cacheable metadata object.

protected string hash(string $identifier)

Hashes the given string.

Parameters

string $identifier

The string to be hashed.

Return Value

string

The hash.