Module: Redistat::Connection
- Defined in:
- lib/redistat/connection.rb
Constant Summary collapse
- REQUIRED_SERVER_VERSION =
"1.3.10"
- MIN_EXPIRE_SERVER_VERSION =
"2.1.3"
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
22 23 24 25 26 27 28 29 |
# File 'lib/redistat/connection.rb', line 22 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
42 43 44 |
# File 'lib/redistat/connection.rb', line 42 def connections @connections ||= {} end |
.create(options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/redistat/connection.rb', line 31 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
15 16 17 18 19 20 |
# File 'lib/redistat/connection.rb', line 15 def get(ref = nil) ref ||= :default synchronize do connections[references[ref]] || create end end |
.references ⇒ Object
46 47 48 |
# File 'lib/redistat/connection.rb', line 46 def references @references ||= {} end |