Merge pull request #2118 from bf4/only_calculate_cache_key_when_caching

Do not calculate cache_key unless caching
This commit is contained in:
Benjamin Fleischer 2017-04-30 21:17:31 -07:00 committed by GitHub
commit afe0183f21

View File

@ -226,8 +226,9 @@ module ActiveModel
end
end
def fetch(adapter_instance, cache_options = serializer_class._cache_options, key = cache_key(adapter_instance))
def fetch(adapter_instance, cache_options = serializer_class._cache_options, key = nil)
if serializer_class.cache_store
key ||= cache_key(adapter_instance)
serializer_class.cache_store.fetch(key, cache_options) do
yield
end