Sha256: f6998c64c6d95c4f963f196f7990c7ddfa37080e25682cf9ea7f431bb0499656
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
module Spree module Api module V2 module Caching extend ActiveSupport::Concern def collection_cache_key(collection) params.delete(:page) if params[:page] == 1 cache_key_parts = [ collection.cache_key_with_version, resource_includes, sparse_fields, serializer_params_cache_key, params[:sort]&.strip, params[:page]&.to_s&.strip, params[:per_page]&.to_s&.strip, ] cache_key_parts += additional_cache_key_parts if defined?(additional_cache_key_parts) cache_key_parts = cache_key_parts.flatten.join('-') Digest::MD5.hexdigest(cache_key_parts) end def collection_cache_opts { namespace: Spree::Api::Config[:api_v2_collection_cache_namespace], expires_in: Spree::Api::Config[:api_v2_collection_cache_ttl], } end def serializer_params_cache_key serializer_params.values.map do |param| param.try(:cache_key) || param.try(:flatten).try(:join, '-') || param.try(:to_s) end.compact.join('-') end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spree_api-4.10.1 | app/controllers/concerns/spree/api/v2/caching.rb |
spree_api-4.10.0 | app/controllers/concerns/spree/api/v2/caching.rb |