Class: Firehose::Server::Redis
- Inherits:
-
Object
- Object
- Firehose::Server::Redis
- Defined in:
- lib/firehose/server/redis.rb
Overview
Manages redis configuration and connections.
Constant Summary collapse
- DEFAULT_URL =
"redis://127.0.0.1:6379/0".freeze
- KEY_DELIMITER =
":".freeze
- ROOT_KEY =
"firehose".freeze
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
-
.key(*segments) ⇒ Object
Generates keys for all firehose interactions with Redis.
- .url ⇒ Object
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(url = self.class.url) ⇒ Redis
constructor
A new instance of Redis.
Constructor Details
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
11 12 13 |
# File 'lib/firehose/server/redis.rb', line 11 def url @url end |
Class Method Details
.key(*segments) ⇒ Object
Generates keys for all firehose interactions with Redis. Ensures a root key of ‘firehose`
23 24 25 |
# File 'lib/firehose/server/redis.rb', line 23 def self.key(*segments) segments.flatten.unshift(ROOT_KEY).join(KEY_DELIMITER) end |
.url ⇒ Object
27 28 29 |
# File 'lib/firehose/server/redis.rb', line 27 def self.url ENV.fetch("REDIS_URL", DEFAULT_URL) end |
Instance Method Details
#connection ⇒ Object
17 18 19 |
# File 'lib/firehose/server/redis.rb', line 17 def connection EM::Hiredis.connect(@url) end |