Module: Stockpile::YamlRedisConfiguration
- Defined in:
- lib/stockpile/yaml_redis_configuration.rb
Overview
Stockpile::YamlRedisConfiguration
Confiuration object a multiple Redis database cache setup. Reads configuration out of provided ‘.yml` file.
Class Method Summary collapse
- .configuration ⇒ Object
- .extract_compression(settings:) ⇒ Object
- .extract_pool(settings:) ⇒ Object
- .extract_redis(settings:) ⇒ Object
- .parsed_configuration ⇒ Object
- .raw_configuration ⇒ Object
Class Method Details
.configuration ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/stockpile/yaml_redis_configuration.rb', line 25 def configuration parsed_configuration.map do |database, settings| { db: database, pool_configuration: extract_pool(settings: settings), redis_configuration: extract_redis(settings: settings), compression: extract_compression(settings: settings) } end end |
.extract_compression(settings:) ⇒ Object
36 37 38 39 40 |
# File 'lib/stockpile/yaml_redis_configuration.rb', line 36 def extract_compression(settings:) return true if settings['compression'].eql?(true) false end |
.extract_pool(settings:) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/stockpile/yaml_redis_configuration.rb', line 53 def extract_pool(settings:) { size: settings.dig('pool_options', 'size'), timeout: settings.dig('pool_options', 'timeout') } end |
.extract_redis(settings:) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/stockpile/yaml_redis_configuration.rb', line 42 def extract_redis(settings:) sentinels = Stockpile::RedisConnectionsFactory.process_sentinels( sentinels: settings['sentinels'] || '' ) { url: settings['url'], sentinels: sentinels }.delete_if { |_k, v| v.nil? || v.empty? } end |
.parsed_configuration ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/stockpile/yaml_redis_configuration.rb', line 60 def parsed_configuration YAML.safe_load( ERB.new( raw_configuration ).result ) end |
.raw_configuration ⇒ Object
68 69 70 |
# File 'lib/stockpile/yaml_redis_configuration.rb', line 68 def raw_configuration File.open(Stockpile.configuration.configuration_file).read end |