Skip to content

Commit

Permalink
Use :cache_key_with_version when available
Browse files Browse the repository at this point in the history
  • Loading branch information
wasifhossain committed Jan 1, 2019
1 parent 17d0e6b commit 823b558
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 823b558

Please sign in to comment.