Skip to content

Commit a78b43c

Browse files
John Bolligerclaude
andcommitted
Bump to 1.2.0 and document the upgrade
The cache key format changed, so every existing entry becomes a miss. A dynamic finder called with too few arguments now raises ArgumentError rather than caching a record under a nil, and the cache provider validator raises InvalidCacheProvider rather than a bare RuntimeError. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 2b2d32a commit a78b43c

2 files changed

Lines changed: 43 additions & 4 deletions

File tree

README.md

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,44 @@ CI runs this matrix on Ruby 3.1, Ruby 3.4, JRuby 9.4, and JRuby 10.0.
149149
`active_remote` 8.0 requires Ruby 3.2 or later. CI does not run that
150150
version on Ruby 3.1 or JRuby 9.4.
151151

152+
## Upgrading to 1.2.0
153+
154+
### Every cache key changes
155+
156+
Before 1.2.0 the cache key held only the argument values, joined with no
157+
separator. Three different finders shared one cache entry:
158+
159+
```ruby
160+
Customer.cached_find_by_name_and_email("x", "y") # key: "xy"
161+
Customer.cached_find_by_city_and_state("x", "y") # key: "xy" same entry
162+
Customer.cached_find_by_id("xy") # key: "xy" same entry
163+
```
164+
165+
The key now names each field, so each finder gets its own entry:
166+
167+
```ruby
168+
Customer.cached_find_by_name_and_email("x", "y") # key: "email.y/name.x"
169+
```
170+
171+
Every existing cache entry becomes a miss after the upgrade. Expect one cold
172+
period. The gem already causes this on an ActiveSupport upgrade, through
173+
`RUBY_AND_ACTIVE_SUPPORT_VERSION`.
174+
175+
### A bad call now raises
176+
177+
A dynamic finder called with too few arguments used to pass `nil` for the
178+
missing field and cache the result. It now raises `ArgumentError`:
179+
180+
```ruby
181+
Customer.cached_find_by_email_and_name("only_one") # => ArgumentError
182+
```
183+
184+
### The cache provider validator raises a new class
185+
186+
`ActiveRemote::Cached::Cache::InvalidCacheProvider` replaces the bare
187+
`RuntimeError` that `ActiveRemote::Cached.cache` raised for a provider that is
188+
missing a method.
189+
152190
## Known behavior
153191

154192
Two behaviors are recorded in the specs. Neither is fixed. Read
@@ -161,9 +199,10 @@ method named `not_cached_find_by_guid` resolves to `cached_find_by_guid`.
161199

162200
### A subclass has its own empty cached_methods list
163201

164-
A subclass inherits the finder methods its parent defined. It does not inherit
165-
the `cached_methods` list. The parent accepts the finder arguments in any
166-
order. The subclass accepts them only in the order the method was defined.
202+
A subclass inherits the finder methods its parent defined, and the options
203+
those finders were declared with. It does not inherit the `cached_methods`
204+
list. The parent accepts the finder arguments in any order. The subclass
205+
accepts them only in the order the method was defined.
167206

168207
```ruby
169208
Parent.cached_find_by_beta_and_alpha('B', 'A') # works

lib/active_remote/cached/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module ActiveRemote
44
module Cached
5-
VERSION = '1.1.1'
5+
VERSION = '1.2.0'
66
end
77
end

0 commit comments

Comments
 (0)