Skip to content

Add multi-level caching and stampede protection (v1.7.0)#62

Merged
eclectic-coding merged 3 commits into
mainfrom
feature/v1.7.0
Jun 2, 2026
Merged

Add multi-level caching and stampede protection (v1.7.0)#62
eclectic-coding merged 3 commits into
mainfrom
feature/v1.7.0

Conversation

@eclectic-coding
Copy link
Copy Markdown
Owner

@eclectic-coding eclectic-coding commented Jun 2, 2026

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; optional promote_expires_in: sets L1 TTL after promotion
  • store: [l1, l2] shorthand on memoize — Array is automatically converted to Stores::Multilevel
  • Stores::XFetch — wraps any store with the XFetch probabilistic early-expiry algorithm; stores a {value:, expires_at:} envelope so the formula now − (delta × beta × log(rand)) ≥ expires_at can fire on read; configurable beta: (aggressiveness, default 1.0) and delta: (estimated computation time, default 0.1 s)
  • stampede_protection: option on memoize — same XFetch algorithm for the per-instance in-process cache; measures actual elapsed_time per miss and stores it as delta; accepts true (beta=1.0) or a Numeric; requires ttl:; incompatible with store: and ractor_safe:

Test plan

  • bundle exec rake — 908 examples, 0 failures, lint clean
  • Stores::Multilevel: read-through promotion, write/delete/clear/keys to all levels, promote_expires_in:, validation, store: Array shorthand
  • Stores::XFetch: basic read/write, hard expiry, probabilistic early expiry with extreme beta, no-TTL values, delete/clear/keys, validation
  • stampede_protection:: caches normally, stores delta in record, triggers early recomputation with large delta/beta, fiber_local and shared cache paths, validation errors, safe_memoize_options default
  • CircuitBreaker: write/delete/clear/keys rescue paths (previously zero-hit) now covered

🤖 Generated with Claude Code

eclectic-coding and others added 3 commits June 2, 2026 15:27
- 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>
@eclectic-coding eclectic-coding merged commit 317ab22 into main Jun 2, 2026
4 checks passed
@eclectic-coding eclectic-coding deleted the feature/v1.7.0 branch June 2, 2026 19:37
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.

v1.7.0: Stampede protection via probabilistic early expiry (XFetch) v1.7.0: Multi-level (L1/L2) cache store

1 participant