Sha256: baf455408c8bed68ade4300f55d19f358e28d12fa2113ddbda5b003347ca7114
Contents?: true
Size: 964 Bytes
Versions: 30
Compression:
Stored size: 964 Bytes
Contents
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) 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
30 entries across 30 versions & 1 rubygems