Class: LaunchDarkly::Impl::Integrations::Redis::RedisStoreImplBase

Inherits:
Object
  • Object
show all
Defined in:
lib/ldclient-rb/impl/integrations/redis_impl.rb

Overview

Since:

  • 5.5.0

Direct Known Subclasses

RedisBigSegmentStore, RedisFeatureStoreCore

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ RedisStoreImplBase

Returns a new instance of RedisStoreImplBase.

Since:

  • 5.5.0



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/ldclient-rb/impl/integrations/redis_impl.rb', line 107

def initialize(opts)
  unless REDIS_ENABLED
    raise RuntimeError.new("can't use #{description} because one of these gems is missing: redis, connection_pool")
  end

  @pool = create_redis_pool(opts)

  # shutdown pool on close unless the client passed a custom pool and specified not to shutdown
  @pool_shutdown_on_close = !opts[:pool] || opts.fetch(:pool_shutdown_on_close, true)

  @prefix = opts[:prefix] || LaunchDarkly::Integrations::Redis::default_prefix
  @logger = opts[:logger] || Config.default_logger
  @test_hook = opts[:test_hook]  # used for unit tests, deliberately undocumented

  @stopped = Concurrent::AtomicBoolean.new

  with_connection do |redis|
    @logger.info("#{description}: using Redis instance at #{redis.connection[:host]}:#{redis.connection[:port]} and prefix: #{@prefix}")
  end
end

Instance Method Details

#stopObject

Since:

  • 5.5.0



128
129
130
131
132
133
# File 'lib/ldclient-rb/impl/integrations/redis_impl.rb', line 128

def stop
  if @stopped.make_true
    return unless @pool_shutdown_on_close
    @pool.shutdown { |redis| redis.close }
  end
end