Class: HTTP::Session::Options::CacheOption
- Inherits:
-
Object
- Object
- HTTP::Session::Options::CacheOption
- Includes:
- Optionable
- Defined in:
- lib/http/session/options/cache_option.rb
Instance Attribute Summary collapse
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
-
#initialize(opts) ⇒ CacheOption
constructor
A new instance of CacheOption.
-
#private_cache? ⇒ Boolean
True when it is a private cache.
-
#shared_cache? ⇒ Boolean
True when it is a shared cache.
Methods included from Optionable
#enabled?, #initialize_options
Constructor Details
#initialize(opts) ⇒ CacheOption
Returns a new instance of CacheOption.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/http/session/options/cache_option.rb', line 14 def initialize(opts) (opts) # Shared Cache / Private Cache @shared = if @options.key?(:shared) raise ArgumentError, ":shared and :private cannot be used at the same time" if @options.key?(:private) !!@options[:shared] elsif @options.key?(:private) !@options[:private] else true end # Cache Store @store = if enabled? store = @options[:store] if store.respond_to?(:read) && store.respond_to?(:write) store else lookup_store(store) end end end |
Instance Attribute Details
#store ⇒ Object (readonly)
Returns the value of attribute store.
8 9 10 |
# File 'lib/http/session/options/cache_option.rb', line 8 def store @store end |
Instance Method Details
#private_cache? ⇒ Boolean
True when it is a private cache.
Private Cache that exists in the client. It is also called local cache or browser cache. It can store and reuse personalized content for a single user.
52 53 54 |
# File 'lib/http/session/options/cache_option.rb', line 52 def private_cache? !shared_cache? end |
#shared_cache? ⇒ Boolean
True when it is a shared cache.
Shared Cache that exists between the origin server and clients (e.g. Proxy, CDN). It stores a single response and reuses it with multiple users
44 45 46 |
# File 'lib/http/session/options/cache_option.rb', line 44 def shared_cache? @shared end |