Skip to content

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

Open

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

Activity

  1. coderabbitai commented on Jul 10, 2026

    @coderabbitai
    🔗 Related PRs

    #177 - feat: caching for local table/scope invalidation [closed]
    #314 - feat(cache): namespace-versioned cache keys for queries and pipes [closed]


    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cacheLocal / shared / tiered caching

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions