final class DoctorContext

Context object holding shared state for Doctor checks.

Bundles all dependencies needed by functional checks to avoid passing many parameters to each check's run() method.

Constants

private TEST_PREFIX

Unique prefix to prevent collision with production data.

Mode-agnostic - just identifies doctor test data.

Methods

__construct(Repository $cache, RedisStore $store, RedisConnection $redis, string $cachePrefix, string $storeName)

Create a new doctor context instance.

string
prefixed(string $value)

Get a value prefixed with the unique doctor test prefix.

string
tagHashKey(string $tag)

Get the full Redis key for a tag hash/ZSET.

string
namespacedKey(array $tags, string $key)

Compute the namespaced key for a tagged cache item in all mode.

string
getTestPrefix()

Get the test prefix constant for cleanup operations.

bool
isAnyMode()

Check if the store is configured for 'any' tag mode.

bool
isAllMode()

Check if the store is configured for 'all' tag mode.

TagMode
getTagMode()

Get the current tag mode.

string
getTagModeValue()

Get the current tag mode as a string value.

array
getTagStoragePatterns(string $tagNamePrefix)

Get patterns to match all tag storage structures with a given tag name prefix.

array
getCacheValuePatterns(string $keyPrefix)

Get patterns to match all cache value keys with a given key prefix.

Details

at line 32
__construct(Repository $cache, RedisStore $store, RedisConnection $redis, string $cachePrefix, string $storeName)

Create a new doctor context instance.

Parameters

Repository $cache
RedisStore $store
RedisConnection $redis
string $cachePrefix
string $storeName

at line 45
string prefixed(string $value)

Get a value prefixed with the unique doctor test prefix.

Used for both cache keys and tag names to ensure complete isolation from production data.

Parameters

string $value

Return Value

string

at line 55
string tagHashKey(string $tag)

Get the full Redis key for a tag hash/ZSET.

Format: "{cachePrefix}_any:tag:{tagName}:entries" or "{cachePrefix}_all:tag:{tagName}:entries"

Parameters

string $tag

Return Value

string

at line 70
string namespacedKey(array $tags, string $key)

Compute the namespaced key for a tagged cache item in all mode.

In all mode, cache keys are prefixed with xxh128 of tag IDs in the requested order. Format: "{xxh128}:{key}"

Parameters

array $tags

The tag names

string $key

The cache key

Return Value

string

The namespaced key

at line 84
string getTestPrefix()

Get the test prefix constant for cleanup operations.

Return Value

string

at line 93
bool isAnyMode()

Check if the store is configured for 'any' tag mode.

In this mode, flushing ANY matching tag removes the item.

Return Value

bool

at line 102
bool isAllMode()

Check if the store is configured for 'all' tag mode.

In this mode, items must match ALL specified tags.

Return Value

bool

at line 110
TagMode getTagMode()

Get the current tag mode.

Return Value

TagMode

at line 118
string getTagModeValue()

Get the current tag mode as a string value.

Return Value

string

at line 135
array getTagStoragePatterns(string $tagNamePrefix)

Get patterns to match all tag storage structures with a given tag name prefix.

Used for cleanup operations to delete dynamically-created test tags. Returns patterns for BOTH tag modes to ensure complete cleanup regardless of current mode (e.g., if config changed between runs):

  • Any mode: {cachePrefix}_any:tag:{tagNamePrefix}*
  • All mode: {cachePrefix}_all:tag:{tagNamePrefix}*

Parameters

string $tagNamePrefix

The prefix to match tag names against

Return Value

array

Patterns to use with SCAN/KEYS commands

at line 157
array getCacheValuePatterns(string $keyPrefix)

Get patterns to match all cache value keys with a given key prefix.

Used for cleanup operations to delete test cache values. Returns patterns for BOTH tag modes to ensure complete cleanup regardless of current mode (e.g., if config changed between runs):

  • Untagged keys: {cachePrefix}{keyPrefix}* (same in both modes)
  • Tagged keys in all mode: {cachePrefix}{xxh128}:{keyPrefix}* (namespaced)

Parameters

string $keyPrefix

The prefix to match cache keys against

Return Value

array

Patterns to use with SCAN/KEYS commands