Module: LaunchDarkly::Integrations::Redis

Defined in:
lib/ldclient-rb/integrations/redis.rb

Overview

Integration with Redis.

Note that in order to use this integration, you must first install the redis and connection-pool gems.

Since:

  • 5.5.0

Class Method Summary collapse

Class Method Details

.default_prefixString

Default value for the prefix option for new_feature_store.

Returns:

  • (String)

    the default key prefix

Since:

  • 5.5.0



29
30
31
# File 'lib/ldclient-rb/integrations/redis.rb', line 29

def self.default_prefix
  'launchdarkly'
end

.default_redis_urlString

Default value for the redis_url option for new_feature_store. This points to an instance of Redis running at localhost with its default port.

Returns:

  • (String)

    the default Redis URL

Since:

  • 5.5.0



20
21
22
# File 'lib/ldclient-rb/integrations/redis.rb', line 20

def self.default_redis_url
  'redis://localhost:6379/0'
end

.new_big_segment_store(opts) ⇒ LaunchDarkly::Interfaces::BigSegmentStore

Creates a Redis-backed Big Segment store.

Big Segments are a specific type of segments. For more information, read the LaunchDarkly documentation: https://docs.launchdarkly.com/home/users/big-segments

To use this method, you must first have the redis and connection-pool gems installed. Then, put the object returned by this method into the store property of your Big Segments configuration (see Config).

Examples:

Configuring Big Segments

store = LaunchDarkly::Integrations::Redis::new_big_segment_store(redis_url: "redis://my-server")
config = LaunchDarkly::Config.new(big_segments: LaunchDarkly::BigSegmentsConfig.new(store: store)
client = LaunchDarkly::LDClient.new(my_sdk_key, config)

Parameters:

  • opts (Hash)

    the configuration options (these are all the same as for new_feature_store, except that there are no caching parameters)

Options Hash (opts):

  • :redis_url (String) — default: default_redis_url

    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) — default: default_prefix

    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

  • :pool (Object)

    custom connection pool, if desired

  • :pool_shutdown_on_close (Boolean)

    whether calling close should shutdown the custom connection pool; this is true by default, and should be set to false only if you are managing the pool yourself and want its lifecycle to be independent of the SDK client

Returns:

Since:

  • 5.5.0



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

def self.new_big_segment_store(opts)
  LaunchDarkly::Impl::Integrations::Redis::RedisBigSegmentStore.new(opts)
end

.new_feature_store(opts = {}) ⇒ LaunchDarkly::Interfaces::FeatureStore

Creates a Redis-backed persistent feature store. For more details about how and why you can use a persistent feature store, see the SDK reference guide.

To use this method, you must first have the redis and connection-pool gems installed. Then, put the object returned by this method into the feature_store property of your client configuration.

Examples:

Configuring the feature store

store = LaunchDarkly::Integrations::Redis::new_feature_store(redis_url: "redis://my-server")
config = LaunchDarkly::Config.new(feature_store: store)
client = LaunchDarkly::LDClient.new(my_sdk_key, config)

Parameters:

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

    the configuration options

Options Hash (opts):

  • :redis_url (String) — default: default_redis_url

    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) — default: default_prefix

    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) — default: 15

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

  • :capacity (Integer) — default: 1000

    maximum number of items in the cache

  • :pool (Object)

    custom connection pool, if desired

  • :pool_shutdown_on_close (Boolean)

    whether calling close should shutdown the custom connection pool; this is true by default, and should be set to false only if you are managing the pool yourself and want its lifecycle to be independent of the SDK client

Returns:

Since:

  • 5.5.0



61
62
63
# File 'lib/ldclient-rb/integrations/redis.rb', line 61

def self.new_feature_store(opts = {})
  LaunchDarkly::Impl::Integrations::Redis::RedisFeatureStore.new(opts)
end