Class: DatastoreRedis::RedisConnection
- Inherits:
-
Object
- Object
- DatastoreRedis::RedisConnection
- Defined in:
- app/models/datastore_redis/redis_connection.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.connection ⇒ Object
16 17 18 19 |
# File 'app/models/datastore_redis/redis_connection.rb', line 16 def self.connection @@redis ||= RedisConnection.new.get_new_connection @@redis end |
Instance Method Details
#connection_string ⇒ Object
3 4 5 6 7 |
# File 'app/models/datastore_redis/redis_connection.rb', line 3 def connection_string conn_string = ENV["REDISTOGO_URL"] conn_string ||= "localhost:6379" conn_string end |
#get_new_connection ⇒ Object
9 10 11 12 13 14 |
# File 'app/models/datastore_redis/redis_connection.rb', line 9 def get_new_connection uri = URI.parse(connection_string) args = {:host => uri.host, :port => uri.port} args[:password] = uri.password if uri.password Redis.new(args) end |