Module: SolidCache::Connections
- Defined in:
- lib/solid_cache/connections.rb,
lib/solid_cache/connections/single.rb,
lib/solid_cache/connections/sharded.rb,
lib/solid_cache/connections/unmanaged.rb
Defined Under Namespace
Classes: Sharded, Single, Unmanaged
Class Method Summary collapse
Class Method Details
.from_config(options) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/solid_cache/connections.rb', line 3 def self.from_config() if .present? || SolidCache.all_shards_config.present? case when NilClass names = SolidCache.all_shard_keys nodes = names.to_h { |name| [ name, name ] } when Array names = nodes = names.to_h { |name| [ name, name ] } when Hash names = .keys nodes = .invert end if (unknown_shards = names - SolidCache.all_shard_keys).any? raise ArgumentError, "Unknown #{"shard".pluralize(unknown_shards)}: #{unknown_shards.join(", ")}" end if names.size == 1 Single.new(names.first) else Sharded.new(names, nodes) end else Unmanaged.new end end |