Class BigSegmentsConfigurationBuilder
- java.lang.Object
-
- com.launchdarkly.sdk.server.integrations.BigSegmentsConfigurationBuilder
-
- All Implemented Interfaces:
ComponentConfigurer<BigSegmentsConfiguration>
public final class BigSegmentsConfigurationBuilder extends java.lang.Object implements ComponentConfigurer<BigSegmentsConfiguration>
Contains methods for configuring the SDK's Big Segments behavior.Big Segments are a specific type of user segments. For more information, read the LaunchDarkly documentation .
If you want non-default values for any of these properties create a builder with
Components.bigSegments(ComponentConfigurer)
, change its properties with the methods of this class, and pass it toLDConfig.Builder.bigSegments(ComponentConfigurer)
LDConfig config = new LDConfig.Builder() .bigSegments(Components.bigSegments(Redis.dataStore().prefix("app1")) .userCacheSize(2000)) .build();
- Since:
- 5.7.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.time.Duration
DEFAULT_STALE_AFTER
The default value forstaleAfter(Duration)
.static java.time.Duration
DEFAULT_STATUS_POLL_INTERVAL
The default value forstatusPollInterval(Duration)
.static int
DEFAULT_USER_CACHE_SIZE
The default value foruserCacheSize(int)
.static java.time.Duration
DEFAULT_USER_CACHE_TIME
The default value foruserCacheTime(Duration)
.
-
Constructor Summary
Constructors Constructor Description BigSegmentsConfigurationBuilder(ComponentConfigurer<BigSegmentStore> storeConfigurer)
Creates a new builder for Big Segments configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BigSegmentsConfiguration
build(ClientContext context)
Called internally by the SDK to create an implementation instance.BigSegmentsConfigurationBuilder
staleAfter(java.time.Duration staleAfter)
Sets the maximum length of time between updates of the Big Segments data before the data is considered out of date.BigSegmentsConfigurationBuilder
statusPollInterval(java.time.Duration statusPollInterval)
Sets the interval at which the SDK will poll the Big Segment store to make sure it is available and to determine how long ago it was updated.BigSegmentsConfigurationBuilder
userCacheSize(int userCacheSize)
Sets the maximum number of users whose Big Segment state will be cached by the SDK at any given time.BigSegmentsConfigurationBuilder
userCacheTime(java.time.Duration userCacheTime)
Sets the maximum length of time that the Big Segment state for a user will be cached by the SDK.
-
-
-
Field Detail
-
DEFAULT_USER_CACHE_SIZE
public static final int DEFAULT_USER_CACHE_SIZE
The default value foruserCacheSize(int)
.- See Also:
- Constant Field Values
-
DEFAULT_USER_CACHE_TIME
public static final java.time.Duration DEFAULT_USER_CACHE_TIME
The default value foruserCacheTime(Duration)
.
-
DEFAULT_STATUS_POLL_INTERVAL
public static final java.time.Duration DEFAULT_STATUS_POLL_INTERVAL
The default value forstatusPollInterval(Duration)
.
-
DEFAULT_STALE_AFTER
public static final java.time.Duration DEFAULT_STALE_AFTER
The default value forstaleAfter(Duration)
.
-
-
Constructor Detail
-
BigSegmentsConfigurationBuilder
public BigSegmentsConfigurationBuilder(ComponentConfigurer<BigSegmentStore> storeConfigurer)
Creates a new builder for Big Segments configuration.- Parameters:
storeConfigurer
- the factory implementation for the specific data store type
-
-
Method Detail
-
userCacheSize
public BigSegmentsConfigurationBuilder userCacheSize(int userCacheSize)
Sets the maximum number of users whose Big Segment state will be cached by the SDK at any given time.To reduce database traffic, the SDK maintains a least-recently-used cache by user key. When a feature flag that references a Big Segment is evaluated for some user who is not currently in the cache, the SDK queries the database for all Big Segment memberships of that user, and stores them together in a single cache entry. If the cache is full, the oldest entry is dropped.
A higher value for
userCacheSize
means that database queries for Big Segments will be done less often for recently-referenced users, if the application has many users, at the cost of increased memory used by the cache.Cache entries can also expire based on the setting of
userCacheTime(Duration)
.- Parameters:
userCacheSize
- the maximum number of user states to cache- Returns:
- the builder
- See Also:
DEFAULT_USER_CACHE_SIZE
-
userCacheTime
public BigSegmentsConfigurationBuilder userCacheTime(java.time.Duration userCacheTime)
Sets the maximum length of time that the Big Segment state for a user will be cached by the SDK.See
userCacheSize(int)
for more about this cache. A higher value foruserCacheTime
means that database queries for the Big Segment state of any given user will be done less often, but that changes to segment membership may not be detected as soon.- Parameters:
userCacheTime
- the cache TTL (a value of null, or a negative value will be changed toDEFAULT_USER_CACHE_TIME
- Returns:
- the builder
- See Also:
DEFAULT_USER_CACHE_TIME
-
statusPollInterval
public BigSegmentsConfigurationBuilder statusPollInterval(java.time.Duration statusPollInterval)
Sets the interval at which the SDK will poll the Big Segment store to make sure it is available and to determine how long ago it was updated.- Parameters:
statusPollInterval
- the status polling interval (a null, zero, or negative value will be changed toDEFAULT_STATUS_POLL_INTERVAL
)- Returns:
- the builder
- See Also:
DEFAULT_STATUS_POLL_INTERVAL
-
staleAfter
public BigSegmentsConfigurationBuilder staleAfter(java.time.Duration staleAfter)
Sets the maximum length of time between updates of the Big Segments data before the data is considered out of date.Normally, the LaunchDarkly Relay Proxy updates a timestamp in the Big Segments store at intervals to confirm that it is still in sync with the LaunchDarkly data, even if there have been no changes to the data. If the timestamp falls behind the current time by the amount specified by
staleAfter
, the SDK assumes that something is not working correctly in this process and that the data may not be accurate.While in a stale state, the SDK will still continue using the last known data, but
BigSegmentStoreStatusProvider.Status
will return true in itsstale
property, and anyEvaluationReason
generated from a feature flag that references a Big Segment will have aEvaluationReason.BigSegmentsStatus
ofEvaluationReason.BigSegmentsStatus.STALE
.- Parameters:
staleAfter
- the time limit for marking the data as stale (a null, zero, or negative value will be changed toDEFAULT_STALE_AFTER
)- Returns:
- the builder
- See Also:
DEFAULT_STALE_AFTER
-
build
public BigSegmentsConfiguration build(ClientContext context)
Description copied from interface:ComponentConfigurer
Called internally by the SDK to create an implementation instance. Applications should not need to call this method.- Specified by:
build
in interfaceComponentConfigurer<BigSegmentsConfiguration>
- Parameters:
context
- provides configuration properties and other components from the current SDK client instance- Returns:
- a instance of the component type
-
-