Class: Stockpile::Redis
- Inherits:
-
Base
- Object
- Base
- Stockpile::Redis
- Defined in:
- lib/stockpile/redis.rb
Overview
A connection manager for Redis.
Constant Summary collapse
- VERSION =
:nodoc:
'2.0'
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Redis
constructor
Create a new Redis connection manager with the provided options.
Constructor Details
#initialize(options = {}) ⇒ Redis
Create a new Redis connection manager with the provided options.
Options
redis
-
Provides the Redis connection options.
namespace
-
Provides the Redis namespace to use, but only if redis-namespace is in use (detected with the existence of Redis::Namespace).
The namespace can also be provided as a key in the
redis
options if it is missing from the main options. If there is no namespace key present in eitheroptions
oroptions[:redis]
, a namespace will be generated from one of the following:$REDIS_NAMESPACE
,Rails.env
(if in Rails), or$RACK_ENV
.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/stockpile/redis.rb', line 28 def initialize( = {}) super @redis_options = (@options.delete(:redis) || {}).dup @redis_options = @redis_options.to_h unless @redis_options.kind_of?(Hash) @namespace = @options.fetch(:namespace) { @redis_options.fetch(:namespace) { ENV['REDIS_NAMESPACE'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] } } @options.delete(:namespace) @redis_options.delete(:namespace) end |