Class: Faraday::HttpCache::Strategies::BaseStrategy Abstract
- Inherits:
-
Object
- Object
- Faraday::HttpCache::Strategies::BaseStrategy
- Defined in:
- lib/faraday/http_cache/strategies/base_strategy.rb
Overview
This class is abstract.
Base class for all strategies.
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the underlying cache store object.
Instance Method Summary collapse
-
#delete(_url) ⇒ Object
abstract
Delete responses from the cache by the url.
-
#initialize(options = {}) ⇒ BaseStrategy
constructor
A new instance of BaseStrategy.
-
#read(_request) ⇒ Object
abstract
Read a response from the cache.
-
#write(_request, _response) ⇒ Object
abstract
Store a response inside the cache.
Constructor Details
#initialize(options = {}) ⇒ BaseStrategy
Returns a new instance of BaseStrategy.
34 35 36 37 38 39 40 |
# File 'lib/faraday/http_cache/strategies/base_strategy.rb', line 34 def initialize( = {}) @cache = [:store] || Faraday::HttpCache::MemoryStore.new @serializer = [:serializer] || JSON @logger = [:logger] || Logger.new(IO::NULL) @cache_salt = (@serializer.is_a?(Module) ? @serializer : @serializer.class).name assert_valid_store! end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the underlying cache store object.
26 27 28 |
# File 'lib/faraday/http_cache/strategies/base_strategy.rb', line 26 def cache @cache end |
Instance Method Details
#delete(_url) ⇒ Object
This method is abstract.
Delete responses from the cache by the url.
56 57 58 |
# File 'lib/faraday/http_cache/strategies/base_strategy.rb', line 56 def delete(_url) raise NotImplementedError, 'Implement this method in your strategy' end |
#read(_request) ⇒ Object
This method is abstract.
Read a response from the cache.
50 51 52 |
# File 'lib/faraday/http_cache/strategies/base_strategy.rb', line 50 def read(_request) raise NotImplementedError, 'Implement this method in your strategy' end |
#write(_request, _response) ⇒ Object
This method is abstract.
Store a response inside the cache.
44 45 46 |
# File 'lib/faraday/http_cache/strategies/base_strategy.rb', line 44 def write(_request, _response) raise NotImplementedError, 'Implement this method in your strategy' end |