Class: DHC::Caching
- Inherits:
-
Interceptor
- Object
- Interceptor
- DHC::Caching
- Includes:
- ActiveSupport::Configurable
- Defined in:
- lib/dhc/interceptors/caching.rb
Defined Under Namespace
Classes: MultilevelCache
Constant Summary collapse
- CACHE_VERSION =
to control cache invalidation across all applications in case of breaking changes within this inteceptor that do not lead to cache invalidation otherwise
'1'
- FORWARDED_OPTIONS =
Options forwarded to the cache
%i[expires_in race_condition_ttl].freeze
Instance Attribute Summary
Attributes inherited from Interceptor
Instance Method Summary collapse
Methods inherited from Interceptor
#after_request, #all_interceptor_classes, #before_init, #before_response, dup, #initialize, #response
Constructor Details
This class inherits a constructor from DHC::Interceptor
Instance Method Details
#after_response ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/dhc/interceptors/caching.rb', line 48 def after_response return unless response.success? return unless cache?(request) return if response_data.present? multilevel_cache.write( key(request, [:key]), to_cache(response), ) end |
#before_request ⇒ Object
42 43 44 45 46 |
# File 'lib/dhc/interceptors/caching.rb', line 42 def before_request return unless cache?(request) return if response_data.blank? from_cache(request, response_data) end |