Skip to content

feat: add ttl and time_field support to CacheChecker - #12987

Open
Mariam-Amin12 wants to merge 1 commit into
deepset-ai:mainfrom
Mariam-Amin12:add-TTL-support-to-CacheChecker
Open

Mariam-Amin12 wants to merge 1 commit into
deepset-ai:mainfrom
Mariam-Amin12:add-TTL-support-to-CacheChecker

Conversation

@Mariam-Amin12

Copy link
Copy Markdown

Proposed Changes:

Added optional TTL support to CacheChecker to allow cached documents to expire.

  • Added an optional ttl parameter.
  • Added a configurable time_field parameter for the cache timestamp.
  • A cache entry is considered a hit only when its timestamp is within the configured TTL.
  • Missing, malformed, or invalid timestamps are treated as cache misses when TTL is enabled.
  • Preserved the existing behavior when ttl=None.
  • Added support for both synchronous and asynchronous cache checking.

How did you test it?

Added and ran unit tests covering:

  • Fresh cache entries within the TTL
  • Expired cache entries
  • Missing timestamp fields
  • ISO timestamp strings
  • Naive datetime timestamps (no tzinfo)
  • Malformed timestamp strings
  • Non-datetime timestamp values
  • Numeric TTL values (seconds, not just timedelta)
  • Serialization/deserialization round-tripping with ttl and time_field set
  • Behavior when TTL is not configured (backward compatibility)
  • Async CacheChecker behavior with TTL (fresh + expired)

Ran:

hatch run test:unit test/components/caching/

Result: 26 passed

Notes for the reviewer

The existing behavior is preserved when ttl=None. TTL validation is only applied when TTL is configured.

Checklist

@Mariam-Amin12
Mariam-Amin12 requested a review from a team as a code owner September 27, 2026 14:32
@Mariam-Amin12
Mariam-Amin12 requested review from bogdankostic and removed request for a team September 27, 2026 14:32
@vercel

vercel Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

@Mariam-Amin12 is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown
Contributor

Hi @Mariam-Amin12, thanks for your interest in contributing to Haystack! 🙏

⚠️ Issue #12967 is already being addressed by open pull request(s) #12979. Before opening a PR for an issue, please check whether a PR is already linked to it, and consider contributing to the existing PR instead. We may close duplicate PRs to keep the review queue manageable.

This is an automated message to help us keep the review queue healthy.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add TTL / expiration support to CacheChecker

1 participant