Module: SolidCache::Cluster::Connections
- Included in:
- SolidCache::Cluster
- Defined in:
- lib/solid_cache/cluster/connections.rb
Instance Method Summary collapse
- #connection_names ⇒ Object
- #group_by_connection(keys) ⇒ Object
- #initialize(options = {}) ⇒ Object
- #with_connection(name, async: false, &block) ⇒ Object
- #with_connection_for(key, async: false, &block) ⇒ Object
- #with_each_connection(async: false, &block) ⇒ Object
Instance Method Details
#connection_names ⇒ Object
39 40 41 |
# File 'lib/solid_cache/cluster/connections.rb', line 39 def connection_names connections.names end |
#group_by_connection(keys) ⇒ Object
35 36 37 |
# File 'lib/solid_cache/cluster/connections.rb', line 35 def group_by_connection(keys) connections.assign(keys) end |
#initialize(options = {}) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/solid_cache/cluster/connections.rb', line 6 def initialize( = {}) super() @shard_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
29 30 31 32 33 |
# File 'lib/solid_cache/cluster/connections.rb', line 29 def with_connection(name, async: false, &block) connections.with(name) do execute(async, &block) end end |
#with_connection_for(key, async: false, &block) ⇒ Object
23 24 25 26 27 |
# File 'lib/solid_cache/cluster/connections.rb', line 23 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
15 16 17 18 19 20 21 |
# File 'lib/solid_cache/cluster/connections.rb', line 15 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 |