Skip to content

APCuConfigCache

APCu-based configuration cache with warmup for Kubernetes/FrankenPHP deployments This class provides both warmup functionality and drop-in replacement methods for ConfigCache.

It combines the benefits of APCu caching with the standard config cache interface. Benefits: - Zero file I/O after warmup - Pre-compiled configurations stored in memory - Routing trees cached and ready - Drop-in replacement for ConfigCache - Uses igbinary for better serialization performance when available

class APCuConfigCache extends ConfigCache

ExtendsConfigCache
Since1.0.0
SourceConfig/APCuConfigCache.php
MethodDescription
checkConfig(mixed $config, mixed $context = null): mixedNot a path on this cache: a compiled configuration is a value in shared memory here, so there is no file to hand back and nothing sensible to return.
clear(): voidClear all APCu cached data
configure(array<string, mixed> $options): voidConfigure APCu cache settings
getDefaultConfigs(): array<int, string>The core config files, in dependency order, that a cold worker will load.
getStatus(): array<string, mixed>Get warmup status and statistics
isAvailable(): boolCheck if APCu is available and enabled
isIgbinaryAvailable(): boolCheck if igbinary is available for better serialization
isWarmedUp(): boolCheck if APCu cache is warmed up
[`loadValue(string $config, stringnull $context = null): mixed`](#loadvalue)
warmup(array<int, string> $configs = [], string $context = null): array<string, mixed>Warm up all configurations and routing data into APCu
writeCacheFile(string $config, string $cache, mixed $value, ?string $generatedBy = null): voidKeep the compiled configuration’s value in shared memory instead of writing a file.

public static function checkConfig(mixed $config, mixed $context = null): mixed

Not a path on this cache: a compiled configuration is a value in shared memory here, so there is no file to hand back and nothing sensible to return.

The base implementation’s contract — “returns the path of the compiled cache file” — cannot be honoured, and returning a path that was never written would fail later as a missing include. APCuConfigCache::loadValue(), reached through CompiledConfig::value(), is the read path.

ParameterTypeDescription
$configmixed
$contextmixed

Returns mixed

ThrowsWhen
CacheExceptionAlways, while APCu is in use.

public static function clear(): void

Clear all APCu cached data

public static function configure(array<string, mixed> $options): void

Configure APCu cache settings

ParameterTypeDescription
$optionsarray``<``string``, ``mixed``>

public static function getDefaultConfigs(): array<int, string>

The core config files, in dependency order, that a cold worker will load.

Public so the cache:warmup command can compile the same set into the on-disk cache for the non-APCu backend (single source of truth).

Returns array``<``int``, ``string``>

public static function getStatus(): array<string, mixed>

Get warmup status and statistics

Returns array``<``string``, ``mixed``>

public static function isAvailable(): bool

Check if APCu is available and enabled

Returns bool

public static function isIgbinaryAvailable(): bool

Check if igbinary is available for better serialization

Returns bool

public static function isWarmedUp(): bool

Check if APCu cache is warmed up

Returns bool

public static function loadValue(string $config, string|null $context = null): mixed

The value a compiled configuration returns, served from shared memory.

An optional context name.

ParameterTypeDescription
$configstringAn absolute or relative filesystem path to a configuration file.
$context`string““null`

Returns mixed — The compiled configuration’s return value.

public static function warmup(array<int, string> $configs = [], string $context = null): array<string, mixed>

Warm up all configurations and routing data into APCu

The context to warm up for

ParameterTypeDescription
$configsarray``<``int``, ``string``>Array of config files to warm up (relative to config_dir)
$contextstringThe context to warm up for

Returns array``<``string``, ``mixed``> — Warmup statistics

public static function writeCacheFile(string $config, string $cache, mixed $value, ?string $generatedBy = null): void

Keep the compiled configuration’s value in shared memory instead of writing a file.

The handler class that compiled it; only the file cache records it.

ParameterTypeDescription
$configstring
$cachestring
$valuemixedThe declaration the handler compiled.
$generatedBy?``stringThe handler class that compiled it; only the file cache records it.

These come from an ancestor and are documented where they are declared.

MethodDeclared inDescription
addConfigHandlersFile()ConfigCacheSchedules a config handlers file to be loaded.
describeConfigCandidates()ConfigCacheFull-candidate-list counterpart to resolveConfigFormat(): reports not just the physical file that would be loaded, but every sibling that exists and why it lost, so callers building diagnostics (e.g.
describeShadowedConfigDiagnostics()ConfigCacheDiagnostic-object counterpart to describeConfigCandidates(), for callers (console, probe, the future extension) that want to surface “this config is shadowed” the same way every other framework diagnostic is reported, rather than re-deriving a message from the raw {winner, shadowed} shape themselves.
exists()ConfigCacheWhether a config file exists in any supported format, given its canonical (typically .xml) logical path — e.g.
frameworkFingerprint()ConfigCacheA short token identifying the framework build that compiles a config cache.
getCacheName()ConfigCacheConvert a normal filename into a cache filename.
isModified()ConfigCacheCheck if the cached version of a file is up to date.
load()ConfigCacheApply a configuration file to runtime state.
parseConfig()ConfigCacheParses a config file with the ConfigParser for the extension of the given file.
resetAppliedConfigs()ConfigCacheTest isolation and APCuConfigCache::clear(): forget which configs APCuConfigCache::load() has applied.
resetFrameworkFingerprint()ConfigCacheDrop the memoized framework fingerprint.
resetWorldWritableWarnings()ConfigCacheTest isolation: re-arm the once-per-directory world-writable warning.