APCu (APC User Cache) provides shared-memory caching for PHP. The application uses it as the backend of Symfony's app cache.
- File:
docker/php/apcu.ini - Purpose: PHP extension configuration for APCu
- Key Settings:
apc.shm_size=32M- Memory allocation for developmentapc.enable_cli=1- Enable APCu in CLI for Symfony console commandsapc.ttl=0- No automatic expirationapc.user_entries_hint=4096- Expected number of cache entries
- File:
config/packages/cache.yaml - Purpose: binds the framework app cache to
cache.adapter.apcuwith a stableprefix_seed. Services receive it via$cacheItemPool: '@cache.app'(seeconfig/services.yaml).
- Development: 32MB (sufficient for testing)
- Production: Recommend 128MB-512MB based on usage patterns
- Monitoring: Use
apcu_cache_info()to monitor usage and hit rates
- Deployment: APCu cache persists across requests but not deployments
- Manual:
php bin/console cache:pool:clear cache.app - Automatic: Configure TTLs per cache item where volatility demands it
- Graceful Degradation: Symfony falls back cleanly when APCu is
unavailable (e.g. CLI without
apc.enable_cli)
- Symfony Profiler: shows cache operations in the web profiler
- CLI:
php bin/console cache:pool:listlists configured pools - Statistics:
apcu_cache_info()for hits/misses/memory usage
- Namespace: keys are namespaced via
prefix_seed: timetracker - No Persistence: APCu data does not survive server restarts
- Sensitive Data: avoid caching passwords or raw authentication tokens; use short TTLs for anything auth-adjacent