Class: Peek::Adapters::Memcache
- Defined in:
- lib/peek/adapters/memcache.rb
Instance Method Summary collapse
- #get(request_id) ⇒ Object
-
#initialize(options = {}) ⇒ Memcache
constructor
A new instance of Memcache.
- #save(request_id) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Memcache
Returns a new instance of Memcache.
7 8 9 10 |
# File 'lib/peek/adapters/memcache.rb', line 7 def initialize( = {}) @client = .fetch(:client, ::Dalli::Client.new) @expires_in = .fetch(:expires_in, 60 * 30) end |
Instance Method Details
#get(request_id) ⇒ Object
12 13 14 15 16 |
# File 'lib/peek/adapters/memcache.rb', line 12 def get(request_id) @client.get("peek:requests:#{request_id}") rescue ::Dalli::DalliError => e Rails.logger.error "#{e.class.name}: #{e.}" end |
#save(request_id) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/peek/adapters/memcache.rb', line 18 def save(request_id) return false if request_id.blank? @client.add("peek:requests:#{request_id}", Peek.results.to_json, @expires_in) rescue ::Dalli::DalliError => e Rails.logger.error "#{e.class.name}: #{e.}" end |