Module: LaunchDarkly::Integrations::Redis

Defined in:
lib/ldclient-rb/integrations.rb,
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



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

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



12
13
14
# File 'lib/ldclient-rb/integrations/redis.rb', line 12

def self.default_redis_url
  'redis://localhost:6379/0'
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)

    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

Returns:

Since:

  • 5.5.0



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

def self.new_feature_store(opts)
  return RedisFeatureStore.new(opts)
end