Class: RedisRing::Client::ShardConnectionPool

Inherits:
Object
  • Object
show all
Defined in:
lib/redis_ring/client/shard_connection_pool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dbObject (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

#metadataObject (readonly)

Returns the value of attribute metadata.



6
7
8
# File 'lib/redis_ring/client/shard_connection_pool.rb', line 6

def 
  @metadata
end

#passwordObject (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