This week in caching: in-process cache vs distributed cache
The layer people forget exists above Redis:
— In-process (APCu / array cache / local memory): lives in the PHP worker or app process — nanosecond reads, zero network hop. Unbeatable for tiny, hot, read-mostly data (config, feature flags, computed constants).
— Distributed (Redis/Memcached): shared across all servers, survives a worker restart, but every read is a network round-trip (sub-ms, but not free).
— The two-tier pattern: check APCu first, fall back to Redis, fall back to DB. Hottest keys never leave the process; shared state stays consistent across the fleet.
— The trap: putting per-server-mutable data in APCu and expecting consistency — each server has its own copy, so invalidation must hit all of them.
Use in-process for things that rarely change and are read constantly; Redis for everything shared.
Bookmark: Symfony's Cache component docs on chained adapters — clean reference for layering APCu over Redis.
Cache Catch
@CacheCatch
This week in caching: in-process cache vs distributed cache
Этот пост опубликован в Telegram-канале Cache Catch. Подписаться можно по ссылке: @CacheCatch.