Class: LaunchDarkly::Impl::Integrations::Redis::RedisFeatureStore

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

Overview

An implementation of the LaunchDarkly client's feature store that uses a Redis instance. This object holds feature flags and related data received from the streaming API. Feature data can also be further cached in memory to reduce overhead of calls to Redis.

To use this class, you must first have the redis and connection-pool gems installed. Then, create an instance and store it in the feature_store property of your client configuration.

Since:

  • 5.5.0

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ RedisFeatureStore

Constructor for a RedisFeatureStore instance.

Parameters:

  • opts (Hash) (defaults to: {})

    the configuration options

Options Hash (opts):

  • :redis_url (String)

    URL of the Redis instance (shortcut for omitting redis_opts)

  • :redis_opts (Hash)

    options to pass to the Redis constructor (if you want to specify more than just redis_url)

  • :prefix (String)

    namespace prefix to add to all hash keys used by LaunchDarkly

  • :logger (Logger)

    a Logger instance; defaults to Config.default_logger

  • :max_connections (Integer)

    size of the Redis connection pool

  • :expiration (Integer)

    expiration time for the in-memory cache, in seconds; 0 for no local caching

  • :capacity (Integer)

    maximum number of feature flags (or related objects) to cache locally

  • :pool (Object)

    custom connection pool, if desired

  • :pool_shutdown_on_close (Boolean)

    whether calling close should shutdown the custom connection pool.

Since:

  • 5.5.0



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

def initialize(opts = {})
  core = RedisFeatureStoreCore.new(opts)
  @wrapper = LaunchDarkly::Integrations::Util::CachingStoreWrapper.new(core, opts)
end

Class Method Details

.default_prefixObject

Default value for the prefix constructor parameter.

Since:

  • 5.5.0



65
66
67
# File 'lib/ldclient-rb/impl/integrations/redis_impl.rb', line 65

def self.default_prefix
  LaunchDarkly::Integrations::Redis::default_prefix
end

.default_redis_urlObject

Default value for the redis_url constructor parameter; points to an instance of Redis running at localhost with its default port.

Since:

  • 5.5.0



58
59
60
# File 'lib/ldclient-rb/impl/integrations/redis_impl.rb', line 58

def self.default_redis_url
  LaunchDarkly::Integrations::Redis::default_redis_url
end

Instance Method Details

#all(kind) ⇒ Object

Since:

  • 5.5.0



73
74
75
# File 'lib/ldclient-rb/impl/integrations/redis_impl.rb', line 73

def all(kind)
  @wrapper.all(kind)
end

#available?Boolean

Returns:

  • (Boolean)

Since:

  • 5.5.0



50
51
52
# File 'lib/ldclient-rb/impl/integrations/redis_impl.rb', line 50

def available?
  @wrapper.available?
end

#delete(kind, key, version) ⇒ Object

Since:

  • 5.5.0



77
78
79
# File 'lib/ldclient-rb/impl/integrations/redis_impl.rb', line 77

def delete(kind, key, version)
  @wrapper.delete(kind, key, version)
end

#get(kind, key) ⇒ Object

Since:

  • 5.5.0



69
70
71
# File 'lib/ldclient-rb/impl/integrations/redis_impl.rb', line 69

def get(kind, key)
  @wrapper.get(kind, key)
end

#init(all_data) ⇒ Object

Since:

  • 5.5.0



81
82
83
# File 'lib/ldclient-rb/impl/integrations/redis_impl.rb', line 81

def init(all_data)
  @wrapper.init(all_data)
end

#initialized?Boolean

Returns:

  • (Boolean)

Since:

  • 5.5.0



89
90
91
# File 'lib/ldclient-rb/impl/integrations/redis_impl.rb', line 89

def initialized?
  @wrapper.initialized?
end

#monitoring_enabled?Boolean

Returns:

  • (Boolean)

Since:

  • 5.5.0



46
47
48
# File 'lib/ldclient-rb/impl/integrations/redis_impl.rb', line 46

def monitoring_enabled?
  true
end

#stopObject

Since:

  • 5.5.0



93
94
95
# File 'lib/ldclient-rb/impl/integrations/redis_impl.rb', line 93

def stop
  @wrapper.stop
end

#upsert(kind, item) ⇒ Object

Since:

  • 5.5.0



85
86
87
# File 'lib/ldclient-rb/impl/integrations/redis_impl.rb', line 85

def upsert(kind, item)
  @wrapper.upsert(kind, item)
end