Module: SolidCache::Store::Connections
- Included in:
- SolidCache::Store
- Defined in:
- lib/solid_cache/store/connections.rb
Instance Attribute Summary collapse
-
#shard_options ⇒ Object
readonly
Returns the value of attribute shard_options.
Instance Method Summary collapse
- #connections ⇒ Object
- #initialize(options = {}) ⇒ Object
- #with_each_connection(async: false, &block) ⇒ Object
Instance Attribute Details
#shard_options ⇒ Object (readonly)
Returns the value of attribute shard_options.
6 7 8 |
# File 'lib/solid_cache/store/connections.rb', line 6 def @shard_options end |
Instance Method Details
#connections ⇒ Object
37 38 39 |
# File 'lib/solid_cache/store/connections.rb', line 37 def connections @connections ||= SolidCache::Connections.from_config(@shard_options) end |
#initialize(options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/solid_cache/store/connections.rb', line 8 def initialize( = {}) super() if [:clusters].present? if [:clusters].size > 1 raise ArgumentError, "Multiple clusters are no longer supported" else ActiveSupport.deprecator.warn(":clusters is deprecated, use :shards instead.") end @shard_options = .fetch(:clusters).first[:shards] elsif [:cluster].present? ActiveSupport.deprecator.warn(":cluster is deprecated, use :shards instead.") @shard_options = .fetch(:cluster, {})[:shards] else @shard_options = .fetch(:shards, nil) end if [ Array, NilClass ].none? { |klass| @shard_options.is_a? klass } raise ArgumentError, "`shards` is a `#{@shard_options.class.name}`, it should be Array or nil" end end |
#with_each_connection(async: false, &block) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/solid_cache/store/connections.rb', line 29 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 |