Class: Typhoeus::Cache::Dalli
- Inherits:
-
Object
- Object
- Typhoeus::Cache::Dalli
- Defined in:
- lib/typhoeus/cache/dalli.rb
Overview
This module provides a simple way to cache HTTP responses using Dalli.
Instance Method Summary collapse
- #get(request) ⇒ Object
-
#initialize(client = ::Dalli::Client.new, options = {}) ⇒ Dalli
constructor
A new instance of Dalli.
- #set(request, response) ⇒ Object
Constructor Details
#initialize(client = ::Dalli::Client.new, options = {}) ⇒ Dalli
Returns a new instance of Dalli.
14 15 16 17 |
# File 'lib/typhoeus/cache/dalli.rb', line 14 def initialize(client = ::Dalli::Client.new, = {}) @client = client @default_ttl = [:default_ttl] end |
Instance Method Details
#get(request) ⇒ Object
19 20 21 |
# File 'lib/typhoeus/cache/dalli.rb', line 19 def get(request) @client.get(request.cache_key) end |
#set(request, response) ⇒ Object
23 24 25 |
# File 'lib/typhoeus/cache/dalli.rb', line 23 def set(request, response) @client.set(request.cache_key, response, request.cache_ttl || @default_ttl) end |