Class: HTTP::Features::Caching::InMemoryStore
- Inherits:
-
Object
- Object
- HTTP::Features::Caching::InMemoryStore
- Defined in:
- lib/http/features/caching/in_memory_store.rb
Overview
Simple in-memory cache store backed by a Hash
Cache keys are derived from the request method and URI.
Instance Method Summary collapse
-
#initialize ⇒ InMemoryStore
constructor
Create a new empty in-memory store.
-
#lookup(request) ⇒ Entry?
Look up a cached entry for a request.
-
#store(request, entry) ⇒ Entry
Store a cache entry for a request.
Constructor Details
#initialize ⇒ InMemoryStore
Create a new empty in-memory store
23 24 25 |
# File 'lib/http/features/caching/in_memory_store.rb', line 23 def initialize @cache = {} end |
Instance Method Details
#lookup(request) ⇒ Entry?
Look up a cached entry for a request
35 36 37 |
# File 'lib/http/features/caching/in_memory_store.rb', line 35 def lookup(request) @cache[cache_key(request)] end |
#store(request, entry) ⇒ Entry
Store a cache entry for a request
48 49 50 |
# File 'lib/http/features/caching/in_memory_store.rb', line 48 def store(request, entry) @cache[cache_key(request)] = entry end |