Class: Peek::Adapters::Redis

Inherits:
Base
  • Object
show all
Defined in:
lib/peek/adapters/redis.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Redis

Returns a new instance of Redis.



7
8
9
10
# File 'lib/peek/adapters/redis.rb', line 7

def initialize(options = {})
  @client = options.fetch(:client, ::Redis.new)
  @expires_in = Integer(options.fetch(:expires_in, 60 * 30))
end

Instance Method Details

#get(request_id) ⇒ Object



12
13
14
# File 'lib/peek/adapters/redis.rb', line 12

def get(request_id)
  @client.get("peek:requests:#{request_id}")
end

#save(request_id) ⇒ Object



16
17
18
19
20
# File 'lib/peek/adapters/redis.rb', line 16

def save(request_id)
  return false if request_id.blank?

  @client.setex("peek:requests:#{request_id}", @expires_in, Peek.results.to_json)
end