Skip to content

Treat a zero cache ttl as never fresh - #1

Merged
milkway merged 1 commit into
mainfrom
fix/zero-ttl-windows
Sep 29, 2026
Merged

milkway merged 1 commit into
mainfrom
fix/zero-ttl-windows

Conversation

@milkway

@milkway milkway commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Fixes the intermittent failure of test_stale_entries_are_refetched on windows-latest (run 36607307567, Python 3.11).

Cause

_cache.read() treated an entry as stale only when age > ttl. On Windows the clock and NTFS mtimes are coarse, so a response written milliseconds earlier has an age of 0 (or slightly negative), and 0 > 0 is false: with ttl = 0 the cached body was still served. The same applied to users calling set_ttl(0) on Windows, not just to the test.

Fix

read() now returns None whenever ttl <= 0, without comparing timestamps.

41 tests pass and ruff is clean locally (macOS); the Windows jobs here are the real check.

The R package is unaffected — its cache is httr2::req_cache().

🤖 Generated with Claude Code

On Windows the clock and NTFS mtimes are coarse enough that a response
written a moment earlier has an age of 0, so 'age > ttl' kept serving
it with ttl=0. test_stale_entries_are_refetched failed intermittently
on windows-latest for this reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@milkway
milkway merged commit e593aec into main Sep 29, 2026
9 checks passed
@milkway
milkway deleted the fix/zero-ttl-windows branch September 29, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant