Sha256: b27a323f71e689a19af129ef09e69a0a3c0cf8a599fac721f375ddbd0a62fe7d
Contents?: true
Size: 986 Bytes
Versions: 27
Compression:
Stored size: 986 Bytes
Contents
# frozen_string_literal: true require 'active_support' class LHS::Record module RequestCycleCache extend ActiveSupport::Concern class Interceptor < LHC::Interceptor VERSION = 1 CACHED_METHODS = [:get].freeze def before_request request.options = request.options.merge({ cache: { expires_in: 5.minutes, race_condition_ttl: 5.seconds, key: cache_key_for(request), methods: CACHED_METHODS, use: LHS.config.request_cycle_cache } }.merge(request.options)) end private def cache_key_for(request) [ "LHS_REQUEST_CYCLE_CACHE(v#{VERSION})", request.method.upcase, [request.url, request.params.presence].compact.join('?'), "REQUEST=#{LHS::Record::RequestCycleCache::RequestCycleThreadRegistry.request_id}", "HEADERS=#{request.headers.hash}" ].join(' ') end end end end
Version data entries
27 entries across 27 versions & 1 rubygems