Module: SolidCache::Cluster::Connections

Included in:
SolidCache::Cluster
Defined in:
lib/solid_cache/cluster/connections.rb

Instance Method Summary collapse

Instance Method Details

#connection_namesObject



37
38
39
# File 'lib/solid_cache/cluster/connections.rb', line 37

def connection_names
  connections.names
end

#group_by_connection(keys) ⇒ Object



33
34
35
# File 'lib/solid_cache/cluster/connections.rb', line 33

def group_by_connection(keys)
  connections.assign(keys)
end

#initialize(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/solid_cache/cluster/connections.rb', line 4

def initialize(options = {})
  super(options)
  @shard_options = options.fetch(:shards, nil)

  if [ Hash, Array, NilClass ].none? { |klass| @shard_options.is_a? klass }
    raise ArgumentError, "`shards` is a `#{@shard_options.class.name}`, it should be one of Array, Hash or nil"
  end
end

#with_connection(name, async: false, &block) ⇒ Object



27
28
29
30
31
# File 'lib/solid_cache/cluster/connections.rb', line 27

def with_connection(name, async: false, &block)
  connections.with(name) do
    execute(async, &block)
  end
end

#with_connection_for(key, async: false, &block) ⇒ Object



21
22
23
24
25
# File 'lib/solid_cache/cluster/connections.rb', line 21

def with_connection_for(key, async: false, &block)
  connections.with_connection_for(key) do
    execute(async, &block)
  end
end

#with_each_connection(async: false, &block) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/solid_cache/cluster/connections.rb', line 13

def with_each_connection(async: false, &block)
  return enum_for(:with_each_connection) unless block_given?

  connections.with_each do
    execute(async, &block)
  end
end