Skip to content

feat(cache): let fully-resolved cached results outlive their TTL (invalidation-driven lifetime) #405

Description

@taitelee

Requested in the #343 review (#343 (review)): "The only case/reason we NEED all the dependencies to be known is when we want to outlast the TTL, which we don't currently support anyway (but should, we need to open a new issue to track this!)".

Today QueryTimeToTTL (cost-based, clamped 10 s–1 h) is a hard ceiling on every cached entry's lifetime; version-keyed invalidation only ever shortens the effective lifetime (a write bumps a namespace version and the entry's key stops matching). After #343, a pipe or structured-query result whose dependency set is fully resolved and version-maintained is already evicted by every relevant write — for those entries the TTL no longer bounds staleness, it only limits how long a hot, un-written result can keep serving from cache.

Proposal

Let a fully-trusted entry outlive its cost-based TTL — a much longer or effectively unbounded TTL, with memory pressure (Ristretto admission/eviction) as the real bound — because correctness is carried by invalidation, not expiry.

Strictly scoped to trusted resolutions. An entry stays on the short leash when it is:

  • on the database-version fallback (EXPLAIN failed — any write evicts, but the dep set is unknown), or
  • TTL-capped as unresolved/external/pruned (cache.UnresolvedDepsTTLCap — an unfoldable view, a table function / cross-database read / non-local dictionary, or a dead-branch-pruned set).

Prerequisites / considerations

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cacheLocal / shared / tiered caching

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions