loom.core.cache.dependency¶
Classes
Generational tags with monotonic counters in cache backend. |
- class loom.core.cache.dependency.GenerationalDependencyResolver(cache)[source]¶
Bases:
DependencyResolver,BatchFingerprintResolverGenerational tags with monotonic counters in cache backend.
A mutation bumps only the tags it affects (see
bump_from_events()), so updating one row leaves every other cached row of the same entity warm. The bareentitytag stays in every key’s tag list but the framework never bumps it: it is the manual entity-wide flush handle. An operator incrementstag:<entity>by hand to evict every key of that entity at once.- Parameters:
cache (CacheBackend)
- async fingerprint(tags)[source]¶
Compute a composite fingerprint from generation counters of all tags.
- async fingerprint_many(tag_groups)[source]¶
Compute one fingerprint per tag group, reading every counter once.
The distinct tags of every group are read together, in batches, so the cost is one round trip per
COUNTER_BATCH_SIZEdistinct tags instead of one per group.
- async bump_from_events(events)[source]¶
Increment generation counters for the tags affected by mutation events.
Every event bumps
entity:listandentity:id:<k>per id; the event’s owntagsare bumped as they come. The bareentitytag is never bumped by the framework: it is reserved for a manual entity-wide flush.The counters are bumped concurrently rather than one round trip at a time: with K distinct tags, a sequential loop pays K round trips in series, while awaiting them together pays roughly one round trip regardless of K once the backend is network-bound (see the benchmark referenced in the PR that introduced this).
- Parameters:
events (tuple[MutationEvent, ...]) – Mutation events to process.
- Return type:
None