A forwarded answer one instance fetched can serve a cache miss on another instance through ValKey #75

Open
opened 2026-10-31 12:42:01 -04:00 by claude · 0 comments
Owner
  • Draft: INT-6
  • Priority: low (the owner marked it optional)
  • Agent: coder
  • Depends on: #70
  • Decisions: none

Why

Each instance asks the upstream again for answers another instance already holds (ForwardedResponseCache.cs:44).

What changes

  • ValKey is a second level behind the in-process store, never instead of it.
  • On a local miss, GET <prefix>:fwd:<hash of ForwardedResponseCacheKey>.
  • On an upstream answer that the cache stores (same rules as ComputeLifetime, ForwardedResponseCache.cs:31-41), SET the wire bytes plus the validated-Secure flag and the absolute expiry, with PX = lifetime. Any later TTL clamp (#238) applies before this write.
  • A value read back is parsed and must match the key's question, or it is discarded. ValKey is trusted but not blindly.
  • Serve-stale stays local only.
  • A ValKey timeout of 50 ms or more counts as a miss.
  • Files: src/dotnet/src/Ninlil.Dns.Server.Forwarding/Caching/ (a new IForwardedResponseSharedStore and its ValKey implementation), the DI extension.
  • #231 (cached reply bytes) and #238 (TTL clamp) change the same cache later and rebase on this.

Acceptance

  • Test (fails first, RequiresDocker): two forwarding resolvers on one ValKey with a counting fake upstream. Ask host A, then host B; the upstream counts 1.
  • Unit test: a stored value whose question differs from the key is ignored, and the upstream is asked.
  • Unit test: with ValKey unreachable, behaviour equals today's.
  • src/dotnet/tests/Ninlil.Dns.Server.Forwarding.Tests passes.

Source

Owner scope ("optionally a shared forwarded-answer cache", 2026-10-09); DEDUPE.md §2 (INT-6, #231, #238 order).

- **Draft:** INT-6 - **Priority:** low (the owner marked it optional) - **Agent:** coder - **Depends on:** #70 - **Decisions:** none ### Why Each instance asks the upstream again for answers another instance already holds (`ForwardedResponseCache.cs:44`). ### What changes - ValKey is a second level behind the in-process store, never instead of it. - On a local miss, `GET <prefix>:fwd:<hash of ForwardedResponseCacheKey>`. - On an upstream answer that the cache stores (same rules as `ComputeLifetime`, `ForwardedResponseCache.cs:31-41`), `SET` the wire bytes plus the validated-Secure flag and the absolute expiry, with `PX` = lifetime. Any later TTL clamp (#238) applies before this write. - A value read back is parsed and must match the key's question, or it is discarded. ValKey is trusted but not blindly. - Serve-stale stays local only. - A ValKey timeout of 50 ms or more counts as a miss. - Files: `src/dotnet/src/Ninlil.Dns.Server.Forwarding/Caching/` (a new `IForwardedResponseSharedStore` and its ValKey implementation), the DI extension. - #231 (cached reply bytes) and #238 (TTL clamp) change the same cache later and rebase on this. ### Acceptance - [ ] Test (fails first, RequiresDocker): two forwarding resolvers on one ValKey with a counting fake upstream. Ask host A, then host B; the upstream counts 1. - [ ] Unit test: a stored value whose question differs from the key is ignored, and the upstream is asked. - [ ] Unit test: with ValKey unreachable, behaviour equals today's. - [ ] `src/dotnet/tests/Ninlil.Dns.Server.Forwarding.Tests` passes. ### Source Owner scope ("optionally a shared forwarded-answer cache", 2026-10-09); DEDUPE.md §2 (INT-6, #231, #238 order).
claude added this to the Release: ValKey milestone 2026-10-31 12:42:01 -04:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
lantea-one/ninlil#75
No description provided.