Repository navigation
Add optional Active Record feature-state cache - #198
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Concurrent reads can restore invalidated stale values, and expired cache entries can accumulate without bound.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds an optional per-adapter TTL cache for Active Record feature-state reads.
Changes:
- Adds thread-safe feature caching with TTL and cloning.
- Invalidates cached state after committed mutations.
- Adds cache documentation and coverage for reads, writes, transactions, and configuration.
File summaries
| File | Description |
|---|---|
lib/rollout/adapters/active_record.rb |
Integrates caching and commit-aware invalidation. |
lib/rollout/active_record/feature_cache.rb |
Implements the in-process TTL cache. |
spec/cache_spec.rb |
Tests cache behavior and transactions. |
spec/configuration_spec.rb |
Tests TTL validation. |
spec/backend_contract_spec.rb |
Runs backend contracts with caching enabled. |
README.md |
Documents cache configuration and semantics. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 3
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Cache FeatureState by name with a configurable TTL. Mutations still read the database, and cache reads are skipped inside transactions.
Reject in-flight fills after local writes, bypass AR query cache only when the TTL cache is enabled, and defer invalidation until the outer transaction commits.
michal-granec
force-pushed
the
add/active-record-feature-cache
branch
from
September 16, 2026 11:38
b091361 to
22e3616
Compare
michal-granec
changed the base branch from
add/redis-active-record-migration
to
master
September 16, 2026 11:49
AR 7.1 does not accept uncached(dirties: false). Write around the SQL cache in a version-safe way and prime it before asserting TTL refresh.
7.1 always clears the SQL cache on writes, so those examples cannot prime a stale result. Keep them on 7.2+ where uncached(dirties: false) is available.
Make the unit explicit in the adapter option, FeatureCache, specs, and README.
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.
Stacked on #197.
Adds an optional per-feature in-process TTL cache to
rollout-active_record-adapter.Summary
cache_ttl_seconds: 10.FeatureStateby name, including missing features.Test plan
cache_ttlenabled