Skip to content

Commit

Permalink
Use #cache_key_with_key when available
Browse files Browse the repository at this point in the history
In order to keep compatibility between the AMS cache feature and with Rails > 5.1  cache versioning, we have to use the `cache_key_with_version`. 
**NOTE** - This is a quick fix to the issue, if there will be future plans a proper cache versioning with recyclable key needs to be implemented. 

More info: #2287
  • Loading branch information
cintamani authored Oct 1, 2018
1 parent f3a19bd commit 7d498d2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/active_model/serializer/concerns/caching.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ def expand_cache_key(parts)
# Use object's cache_key if available, else derive a key from the object
# Pass the `key` option to the `cache` declaration or override this method to customize the cache key
def object_cache_key
if object.respond_to?(:cache_key)
if object.respond_to?(:cache_key_with_version)
object.cache_key_with_version
elsif object.respond_to?(:cache_key)
object.cache_key
elsif (serializer_cache_key = (serializer_class._cache_key || serializer_class._cache_options[:key]))
object_time_safe = object.updated_at
Expand Down

0 comments on commit 7d498d2

Please sign in to comment.