Class: CrossStub::Stores::Redis

Inherits:
Base
  • Object
show all
Defined in:
lib/cross-stub/stores/redis.rb

Instance Method Summary collapse

Methods inherited from Base

#clear, #get, #set

Constructor Details

#initialize(connection_and_cache_id, truncate = true) ⇒ Redis

Returns a new instance of Redis.



5
6
7
8
9
10
11
# File 'lib/cross-stub/stores/redis.rb', line 5

def initialize(connection_and_cache_id, truncate = true)
  require 'redis'
  connection, @cache_id = connection_and_cache_id.split('/')
  host, port = connection.split(':')
  @redis = ::Redis.new(:host => host, :port => port.to_i)
  super(truncate)
end

Instance Method Details

#currentObject



13
14
15
# File 'lib/cross-stub/stores/redis.rb', line 13

def current
  @cache_id
end

#previousObject



17
18
19
# File 'lib/cross-stub/stores/redis.rb', line 17

def previous
  "#{@cache_id}.stale"
end