Drupal Chained Fast Backend Uses Timestamp Strategy to Balance APCu Speed and Consistency
Drupal’s chained fast cache backend combines local APCu speed with database-backed consistency to address a key challenge in multi-server environments: how to keep caches fast without serving stale data.
In a post by Matt Glaman, cache.backend.chainedfast is described as a two-layer system that pairs a fast but local APCu cache with a shared database backend. Each write records a last-write timestamp in the database while updating both layers, allowing Drupal to track whether locally cached data remains valid across servers.
On read, the backend checks APCu first for performance but validates the cached item against the stored timestamp. If the item predates the last write, Drupal discards it and reloads fresh data from the database, then repopulates APCu for subsequent requests. This approach preserves fast reads while maintaining cross-server consistency.
The design introduces a trade-off: every write effectively invalidates older APCu entries in the same cache bin. As a result, Drupal limits this backend to read-heavy bins such as bootstrap, config, and discovery, where writes are infrequent. In high-write scenarios, the invalidation cost would outweigh the performance benefit. If APCu is unavailable, ChainedFastBackendFactory falls back automatically to the database backend without chaining, requiring no additional configuration.


