Repository navigation
docs: invalidation guidance, Memcached group invalidation, lock options, stored None, what runs on a hit - #448
Merged
Conversation
Dependencies run on every request, since FastAPI resolves them before the @cache wrapper; background tasks added by the handler run only on a miss, while one a dependency adds runs on a hit too. CACHE_FLOW.md no longer claims the handler "does not run at all". Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UTXhK1BtwXTBDaouEcKtpW
APP_CACHE.md says so and shows the alternatives: a sentinel default, has(), or get_or_set(), which does tell them apart. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UTXhK1BtwXTBDaouEcKtpW
…iod jobs (#390) The example now shows blocking, timeout and poll_interval where they live, on the constructor, and a new section explains why a lock does not make a job run once per period and what does. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UTXhK1BtwXTBDaouEcKtpW
A generation counter per group, read with increment(key, 0) and bumped to invalidate, makes a whole group unreachable without enumerating keys; old entries leave through their TTL. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UTXhK1BtwXTBDaouEcKtpW
invalidate() drops the one key built from the request; other query strings and Vary variants of the same resource keep the old data. clear_path(path, include_params=True) drops every variant, on backends that can enumerate keys. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UTXhK1BtwXTBDaouEcKtpW
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.
Fixes #329
Fixes #391
Fixes #390
Fixes #389
Fixes #388
Summary
Five documentation gaps, one commit each, English and zh-TW in every commit:
HTTP_CACHING.md: new "What still runs on a hit" section. Dependencies run on every request (FastAPI resolves them before the@cachewrapper), a handler's background tasks run only on a miss, and a task added by a dependency's ownBackgroundTasksruns on a hit too (checked with a probe app).CACHE_FLOW.mdno longer says the handler "does not run at all".APP_CACHE.md:get()returnsNonefor a storedNoneas well as a miss; shows the sentinel-default pattern and points tohas()andget_or_set(), which do tell them apart.LOCK.md: the example showsblocking,timeoutandpoll_intervalon the constructor, and a new "Once per period across workers" section explains why a lock reruns the job and showsCacheManager.add(f"digest:{hour}", True, ttl=3600)instead, including what to do when the job fails.APP_CACHE.md: "Group invalidation on Memcached" recipe: a generation counter read withbackend.increment(key, 0)(atomic, creates at 0), embedded in each key, bumped to invalidate; notes the extra read per lookup, the need for a TTL on entries, and bumping by a timestamp step if the backend can lose the counter.HTTP_CACHING.md: "After a write:invalidate()orclear_path()" explains thatinvalidate()drops one key while other query strings andVaryvariants keep the old data, when to useclear_path(path, include_params=True), and that Memcached needs the docs: group invalidation recipe for CacheManager on Memcached #389 recipe instead.Both sites build with
zensical build --strict. Docs only, no changelog fragment.Checklist
tests/cover the change (not applicable: docs)changelog.d/<issue>.<section>.md(required for any change underfastapi_cachex/) (not applicable)uv run pre-commit run --all-filesanduv run pytestpass🤖 Generated with Claude Code
https://claude.ai/code/session_01UTXhK1BtwXTBDaouEcKtpW
Generated by Claude Code