Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Prompt cache expiry rounds timestamps down to whole seconds and considers an item expired only when the rounded time is greater than its expiry. As a result, a positive TTL can be treated as fresh for almost one additional second. For example, an item cached at 100.75 seconds with a one-second TTL is still considered fresh at 101.75 seconds, so the usual stale-while-revalidate refresh is not scheduled at the configured expiry.
Keep fractional timestamp precision and treat the item as expired once the TTL has elapsed. The stale-while-revalidate behavior remains unchanged: the first request after expiry can still receive stale data while the background refresh runs.
This addresses positive-TTL timing; #2114 separately addresses writing to the cache when the caller explicitly requests a zero TTL.
Type of change
Verification
ruff check .,ruff format --check .,mypy langfuse --no-error-summary, and the repository pre-commit hooks passed.LANGFUSE_TRACING_ENVIRONMENT=unitwas set for the run. Those eight environment-propagation cases all passed when rerun with that variable unset. The entire unit suite was not rerun after changing the environment.Checklist
code_review.md..env.templateif needed. (No documentation change was needed.)

Confidence Score: 5/5
The PR appears safe to merge.Summary
Prompt cache entries now keep fractional timestamps and expire when their full TTL has elapsed.
Aafimalek explicitly deferred zero-TTL cache writes to #2114.
Reviews (1) · Last reviewed commit: "fix(prompts): honor cache expiry at frac..." · Reviewed by Greptile