Class: Rack::Cache::EntityStore::Juno
- Inherits:
-
Rack::Cache::EntityStore
- Object
- Rack::Cache::EntityStore
- Rack::Cache::EntityStore::Juno
- Extended by:
- JunoResolver
- Defined in:
- lib/rack/cache/juno.rb
Constant Summary
Constants inherited from Rack::Cache::EntityStore
Instance Method Summary collapse
- #exist?(key) ⇒ Boolean
-
#initialize(cache) ⇒ Juno
constructor
A new instance of Juno.
- #open(key) ⇒ Object
- #purge(key) ⇒ Object
- #read(key) ⇒ Object
- #write(body, ttl = 0) ⇒ Object
Methods included from JunoResolver
Constructor Details
#initialize(cache) ⇒ Juno
Returns a new instance of Juno.
60 61 62 |
# File 'lib/rack/cache/juno.rb', line 60 def initialize(cache) @cache = cache end |
Instance Method Details
#exist?(key) ⇒ Boolean
69 70 71 |
# File 'lib/rack/cache/juno.rb', line 69 def exist?(key) @cache.key?(key) end |
#open(key) ⇒ Object
64 65 66 67 |
# File 'lib/rack/cache/juno.rb', line 64 def open(key) data = read(key) data && [data] end |
#purge(key) ⇒ Object
84 85 86 87 |
# File 'lib/rack/cache/juno.rb', line 84 def purge(key) @cache.delete(key) nil end |
#read(key) ⇒ Object
73 74 75 |
# File 'lib/rack/cache/juno.rb', line 73 def read(key) @cache[key] end |
#write(body, ttl = 0) ⇒ Object
77 78 79 80 81 82 |
# File 'lib/rack/cache/juno.rb', line 77 def write(body, ttl = 0) buf = StringIO.new key, size = slurp(body) { |part| buf.write(part) } @cache.store(key, buf.string, ttl == 0 ? {} : {:expires => ttl}) [key, size] end |