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



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ldclient-rb/impl/integrations/redis_impl.rb', line 17

def initialize(opts)
  if !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(false)

  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



38
39
40
41
42
43
# File 'lib/ldclient-rb/impl/integrations/redis_impl.rb', line 38

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