Skip to content

Commit

Permalink
Move cache key generation inside caching section
Browse files Browse the repository at this point in the history
  • Loading branch information
lgebhardt committed Jan 13, 2024
1 parent 3cb5afc commit 276438f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/jsonapi/resource_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ def populate!(serializer, context, options)
@resource_klasses.each_key do |resource_klass|
missed_resource_ids[resource_klass] ||= []

serializer_config_key = serializer.config_key(resource_klass).gsub("/", "_")
context_json = resource_klass.attribute_caching_context(context).to_json
context_b64 = JSONAPI.configuration.resource_cache_digest_function.call(context_json)
context_key = "ATTR-CTX-#{context_b64.gsub("/", "_")}"

if resource_klass.caching?
serializer_config_key = serializer.config_key(resource_klass).gsub("/", "_")
context_json = resource_klass.attribute_caching_context(context).to_json
context_b64 = JSONAPI.configuration.resource_cache_digest_function.call(context_json)
context_key = "ATTR-CTX-#{context_b64.gsub("/", "_")}"

cache_ids = @resource_klasses[resource_klass].map do |(k, v)|
# Store the hashcode of the cache_field to avoid storing objects and to ensure precision isn't lost
# on timestamp types (i.e. string conversions dropping milliseconds)
Expand Down

0 comments on commit 276438f

Please sign in to comment.