App Cache vs DB Cache
Layer the cache.
Overview
App cache versus DB cache is not really a choice; the right answer is layered caching, where in-process app caches absorb the hottest reads, shared Redis or memcached caches absorb the next tier, and the database itself caches what gets through. Each layer trades scope for shared state: the app cache is fast but per-process and harder to invalidate; the DB cache is shared but pays a network round trip. Picking the right tier per data class is the discipline.
- Layer the cache. Per-tier caching from in-process to shared to database; each layer absorbs a portion of the read load.
- App cache: per-process. In-memory map or LRU; nanosecond access; per-process state means invalidation is harder than for shared caches.
- DB cache: shared. Redis or memcached; millisecond access over the network; shared invalidation across all app instances.
- Per-data tier plus invalidation. Per-data-class right tier (rarely-changing in app, frequently-shared in DB cache); per-tier invalidation strategy that matches consistency requirements.
The approach
The practical approach is to layer caches deliberately rather than pick one, route per-data-class to the appropriate tier (rarely-changing reference data goes to in-process, frequently-shared state goes to Redis), define invalidation per tier with clear rules for when each layer must update, and document the per-cache rationale so the next engineer can reason about the layering rather than re-deriving it.
- Per-tier cache. Each tier absorbs reads it is best suited for; the layering reduces total backend load.
- App cache for per-process state. In-process LRU for rarely-changing reference data; nanosecond access without network hops.
- DB cache for shared state. Redis or memcached for state that must be shared across app instances; millisecond access with shared invalidation.
- Cache invalidation plus documented strategy. Per-tier invalidation rules; per-cache rationale committed to the schema documentation for operational review.
Why this compounds
Cache layering compounds across services. Each correctly-placed cache absorbs reads at the cheapest possible tier; each layer reduces load on the layers behind it; the team builds a vocabulary for matching data class to caching tier that pays off on every new feature. Without the discipline, every cache becomes Redis and the in-process savings get left on the table.
- Performance. Right cache tier matches access pattern; the user-facing latency drops at the layer best suited to absorb the read.
- Cost efficiency. Right cache reduces backend load at every layer; the database serves writes plus the misses, not the full read fleet.
- Operational fit. Right cache matches consistency requirements; the invalidation cost matches the consistency demand.
- Institutional knowledge. Each cache decision teaches access-pattern reasoning; the team learns which workloads belong at which tier.
Cache layering discipline is an engineering discipline that pays off across years. Nova AI Ops integrates with caching telemetry, surfaces hit-rate patterns, and supports the team’s caching discipline.