Add multi-level caching and stampede protection (v1.7.0)#62
Merged
Conversation
- Stores::Multilevel — chains 2+ Stores::Base adapters; reads walk L1→L2, miss in L1 promotes from L2; writes/deletes/clears hit all levels; optional promote_expires_in: controls L1 TTL after promotion - store: [l1, l2] shorthand on memoize — auto-creates Multilevel store - Stores::XFetch — wraps any store with the XFetch probabilistic early expiry algorithm; stores value+expires_at envelope; configurable beta: (aggressiveness) and delta: (estimated computation time, default 0.1 s) - stampede_protection: option on memoize — enables XFetch for the per-instance in-process cache; stores actual elapsed_time as delta on each miss; accepts true (beta=1.0) or Numeric; requires ttl:; incompatible with store: (use Stores::XFetch) and ractor_safe: - 34 new tests covering all three features; 899 total, 0 failures Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Update CHANGELOG, ROADMAP, and README for Stores::Multilevel, store: Array shorthand, Stores::XFetch, and stampede_protection:. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- CircuitBreaker: add tests for write/delete/clear/keys rescue blocks (lines 91, 100, 107, 117-118 were zero-hit) - stampede_protection: add tests for fiber_local and shared cache paths (lines 383-388, 469-474 were zero-hit) 908 examples, 0 failures Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Closes #57
Closes #58
Summary
Stores::Multilevel— chains 2+ store adapters (L1/L2/…); reads walk fastest-to-slowest and promote values on miss; writes/deletes/clears hit all levels; optionalpromote_expires_in:sets L1 TTL after promotionstore: [l1, l2]shorthand onmemoize— Array is automatically converted toStores::MultilevelStores::XFetch— wraps any store with the XFetch probabilistic early-expiry algorithm; stores a{value:, expires_at:}envelope so the formulanow − (delta × beta × log(rand)) ≥ expires_atcan fire on read; configurablebeta:(aggressiveness, default 1.0) anddelta:(estimated computation time, default 0.1 s)stampede_protection:option onmemoize— same XFetch algorithm for the per-instance in-process cache; measures actualelapsed_timeper miss and stores it asdelta; acceptstrue(beta=1.0) or aNumeric; requiresttl:; incompatible withstore:andractor_safe:Test plan
bundle exec rake— 908 examples, 0 failures, lint cleanStores::Multilevel: read-through promotion, write/delete/clear/keys to all levels,promote_expires_in:, validation,store: ArrayshorthandStores::XFetch: basic read/write, hard expiry, probabilistic early expiry with extreme beta, no-TTL values, delete/clear/keys, validationstampede_protection:: caches normally, stores delta in record, triggers early recomputation with large delta/beta, fiber_local and shared cache paths, validation errors,safe_memoize_optionsdefaultCircuitBreaker: write/delete/clear/keys rescue paths (previously zero-hit) now covered🤖 Generated with Claude Code