Class: RedisRing::Client::ShardConnectionPool
- Inherits:
-
Object
- Object
- RedisRing::Client::ShardConnectionPool
- Defined in:
- lib/redis_ring/client/shard_connection_pool.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
Instance Method Summary collapse
- #connection(shard_number) ⇒ Object
-
#initialize(metadata, password, db) ⇒ ShardConnectionPool
constructor
A new instance of ShardConnectionPool.
Constructor Details
#initialize(metadata, password, db) ⇒ ShardConnectionPool
Returns a new instance of ShardConnectionPool.
8 9 10 11 12 13 |
# File 'lib/redis_ring/client/shard_connection_pool.rb', line 8 def initialize(, password, db) @metadata = @password = password @db = db @connections = {} end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
6 7 8 |
# File 'lib/redis_ring/client/shard_connection_pool.rb', line 6 def db @db end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
6 7 8 |
# File 'lib/redis_ring/client/shard_connection_pool.rb', line 6 def @metadata end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
6 7 8 |
# File 'lib/redis_ring/client/shard_connection_pool.rb', line 6 def password @password end |
Instance Method Details
#connection(shard_number) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/redis_ring/client/shard_connection_pool.rb', line 15 def connection(shard_number) connection, conn_id = @connections[shard_number] = .shard(shard_number) unless conn_id == .to_sym connection = new_connection(.host, .port, db, password) conn_id = .to_sym @connections[shard_number] = [connection, conn_id] end connection end |