7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/concerns/spree/api/v2/caching.rb', line 7
def collection_cache_key(collection)
ids_and_timestamps = collection.unscope(:includes).unscope(:order).pluck(:id, :updated_at)
ids = ids_and_timestamps.map(&:first)
max_updated_at = ids_and_timestamps.map(&:last).max
cache_key_parts = [
self.class.to_s,
max_updated_at,
ids,
resource_includes,
sparse_fields,
serializer_params,
params[:sort]&.strip,
params[:page]&.to_s&.strip,
params[:per_page]&.to_s&.strip,
].flatten.join('-')
Digest::MD5.hexdigest(cache_key_parts)
end
|