Class: Rack::AcornCache
- Inherits:
-
Object
- Object
- Rack::AcornCache
- Defined in:
- lib/acorn_cache/cache_control_header.rb,
lib/acorn_cache/cache_maintenance.rb,
lib/acorn_cache/cache_controller.rb,
lib/acorn_cache/server_response.rb,
lib/acorn_cache/freshness_rules.rb,
lib/acorn_cache/cached_response.rb,
lib/acorn_cache/app_exception.rb,
lib/acorn_cache/cache_writer.rb,
lib/acorn_cache/cache_reader.rb,
lib/acorn_cache/storage.rb,
lib/acorn_cache/request.rb,
lib/acorn_cache/config.rb,
lib/acorn_cache.rb
Defined Under Namespace
Modules: CacheReader, CacheWriter, FreshnessRules, Storage Classes: AppException, CacheControlHeader, CacheController, CacheMaintenance, CachedResponse, Configuration, NullCachedResponse, Request, ServerResponse
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
Instance Method Summary collapse
- #_call(env) ⇒ Object
- #call(env) ⇒ Object
-
#initialize(app) ⇒ AcornCache
constructor
A new instance of AcornCache.
Constructor Details
#initialize(app) ⇒ AcornCache
Returns a new instance of AcornCache.
4 5 6 |
# File 'lib/acorn_cache.rb', line 4 def initialize(app) @app = app end |
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
3 4 5 |
# File 'lib/acorn_cache/config.rb', line 3 def configuration @configuration end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
6 7 8 9 |
# File 'lib/acorn_cache/config.rb', line 6 def self.configure self.configuration ||= Configuration.new yield(configuration) end |
Instance Method Details
#_call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/acorn_cache.rb', line 12 def _call(env) request = Request.new(env) return @app.call(env) unless request.cacheable? begin CacheController.new(request, @app).response.to_a rescue AppException => e raise e.caught_exception rescue => e @app.call(env) end end |
#call(env) ⇒ Object
8 9 10 |
# File 'lib/acorn_cache.rb', line 8 def call(env) dup._call(env) end |