Module: Redistat::Connection
- Defined in:
- lib/redistat/connection.rb
Constant Summary collapse
- REQUIRED_SERVER_VERSION =
"1.3.10"
Class Method Summary collapse
- .add(conn, ref = nil) ⇒ Object
- .connections ⇒ Object
- .create(options = {}) ⇒ Object
-
.get(ref = nil) ⇒ Object
TODO: clean/remove all ref-less connections.
- .references ⇒ Object
Class Method Details
.add(conn, ref = nil) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/redistat/connection.rb', line 21 def add(conn, ref = nil) ref ||= :default synchronize do check_redis_version(conn) references[ref] = conn.client.id connections[conn.client.id] = conn end end |
.connections ⇒ Object
41 42 43 |
# File 'lib/redistat/connection.rb', line 41 def connections @connections ||= {} end |
.create(options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/redistat/connection.rb', line 30 def create( = {}) synchronize do = .clone ref = .delete(:ref) || :default .reverse_merge!() conn = (connections[connection_id()] ||= connection()) references[ref] = conn.client.id conn end end |
.get(ref = nil) ⇒ Object
TODO: clean/remove all ref-less connections
14 15 16 17 18 19 |
# File 'lib/redistat/connection.rb', line 14 def get(ref = nil) ref ||= :default synchronize do connections[references[ref]] || create end end |
.references ⇒ Object
45 46 47 |
# File 'lib/redistat/connection.rb', line 45 def references @references ||= {} end |