Skip to content

Commit 5f11e13

Browse files
committed
Move cache key generation inside caching section
1 parent 060d998 commit 5f11e13

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/jsonapi/resource_set.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ def populate!(serializer, context, options)
3939
@resource_klasses.each_key do |resource_klass|
4040
missed_resource_ids[resource_klass] ||= []
4141

42-
serializer_config_key = serializer.config_key(resource_klass).gsub("/", "_")
43-
context_json = resource_klass.attribute_caching_context(context).to_json
44-
context_b64 = JSONAPI.configuration.resource_cache_digest_function.call(context_json)
45-
context_key = "ATTR-CTX-#{context_b64.gsub("/", "_")}"
46-
4742
if resource_klass.caching?
43+
serializer_config_key = serializer.config_key(resource_klass).gsub("/", "_")
44+
context_json = resource_klass.attribute_caching_context(context).to_json
45+
context_b64 = JSONAPI.configuration.resource_cache_digest_function.call(context_json)
46+
context_key = "ATTR-CTX-#{context_b64.gsub("/", "_")}"
47+
4848
cache_ids = @resource_klasses[resource_klass].map do |(k, v)|
4949
# Store the hashcode of the cache_field to avoid storing objects and to ensure precision isn't lost
5050
# on timestamp types (i.e. string conversions dropping milliseconds)

0 commit comments

Comments
 (0)