Skip to content

Commit 8760752

Browse files
docs: document Valkey L2 storage, write-through L1, and cache metrics
Signed-off-by: larry-dalmeida <hello@larrydalmeida.com>
1 parent df7551d commit 8760752

1 file changed

Lines changed: 28 additions & 8 deletions

File tree

docs/reference/filters.md

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3893,17 +3893,37 @@ matching the same key. It has no awareness of other filters in the chain.
38933893
* **`Cache-Control: private` is ignored in force mode.** Audit the upstream
38943894
response before enabling force mode on any authenticated route.
38953895
3896+
**Storage**
3897+
3898+
By default entries are stored in an in-process LRU (L1) local to each pod.
3899+
When `--swarm-valkey-urls` is configured, Valkey becomes the primary shared
3900+
store (L2) accessible by all pods via a client-side consistent hash ring. Every
3901+
read checks L1 first; an L1 hit returns without contacting Valkey.
3902+
3903+
On every successful Valkey write the entry is also written to L1
3904+
(write-through) with a TTL of `min(--cache-l1-ttl, entry.TTL)`. The default is
3905+
60 seconds, bounding how long a pod serves a locally-cached entry before
3906+
falling back to Valkey. Set `--cache-l1-ttl=0` to disable L1 warming and
3907+
restore write-around behaviour (L1 used only when Valkey is unavailable).
3908+
3909+
Explicit deletes (unsafe methods or operator-initiated invalidation) always
3910+
remove the L1 entry unconditionally, regardless of `--cache-l1-ttl`.
3911+
38963912
!!! note
3897-
The LRU store is shared across all `cache()` filter instances. The storage
3898-
budget is divided evenly across 256 internal shards; a single entry larger
3899-
than one shard's budget is dropped with a warning log.
3913+
The in-process LRU (L1) is shared across all `cache()` filter instances on
3914+
the same pod but is local to that pod. When Valkey is configured it acts as
3915+
the cross-pod shared store (L2). The L1 storage budget is divided evenly
3916+
across 256 internal shards; a single entry larger than one shard's budget is
3917+
dropped with a warning log.
39003918
39013919
!!! note
3902-
Three metrics track LRU behaviour: `lru_eviction` (counter, incremented each
3903-
time an entry is evicted due to memory pressure), `lru_bytes` (gauge,
3904-
updated on every eviction to reflect current storage usage in bytes), and
3905-
`lru_oversized` (counter, incremented when an entry is too large to fit in
3906-
any shard and is silently dropped).
3920+
Metrics: `lru_eviction` (counter, incremented each time an L1 entry is
3921+
evicted due to memory pressure), `lru_bytes` (gauge, current L1 usage in
3922+
bytes), `lru_oversized` (counter, entry too large for any shard and
3923+
silently dropped). When Valkey is configured: `l1_hit` (counter, L1 hit
3924+
that bypassed Valkey), `valkey_miss` (counter, Valkey miss that proceeded
3925+
to an upstream fetch), `valkey_get_fallback` and `valkey_set_fallback`
3926+
(counters, reads/writes that fell back to L1 due to a Valkey error).
39073927
39083928
!!! note
39093929
`s-maxage` implies `proxy-revalidate` per [RFC 9111 §5.2.2.10](https://www.rfc-editor.org/rfc/rfc9111#section-5.2.2.10): stale entries

0 commit comments

Comments
 (0)