Module: ContainerConfig::Redis
- Defined in:
- lib/container_config/redis.rb
Overview
Redis configuration module
Class Method Summary collapse
-
.load(key, **options) ⇒ Hash
Loads Redis configuration settings from environment variables, mounted secrets, or the application credentials.
Class Method Details
.load(key, **options) ⇒ Hash
Loads Redis configuration settings from environment variables, mounted secrets, or the application credentials
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/container_config/redis.rb', line 19 def self.load(key, **) host = ContainerConfig.load("#{key}_HOST", **, default: "localhost") port = ContainerConfig.load("#{key}_PORT", **, default: "6379") url = ContainerConfig.load("#{key}_URL", **, default: "redis://#{host}:#{port}") sentinels = sentinel_info(key, **) password = ContainerConfig.load("#{key}_PASSWORD", **) db = ContainerConfig.load("#{key}_DB", **, type: :integer, coerce_nil: false) # Ensure we never pass an empty string to Redis since it will be passed to the Redis AUTH # command as-is and will cause an exception password = nil if password.to_s.strip.empty? redis_config = { url: url, password: password } redis_config[:db] = db if db redis_config[:sentinels] = sentinels unless sentinels.empty? # Add SSL configuration redis_config[:ssl] = ContainerConfig.load("#{key}_SSL", **, default: false) redis_config[:ssl_params] = ssl_params(key, **) redis_config end |