public final class BigSegmentsConfigurationBuilder extends java.lang.Object implements ComponentConfigurer<BigSegmentsConfiguration>
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 to LDConfig.Builder.bigSegments(ComponentConfigurer)
LDConfig config = new LDConfig.Builder()
.bigSegments(Components.bigSegments(Redis.dataStore().prefix("app1"))
.userCacheSize(2000))
.build();
Modifier and Type | Field and Description |
---|---|
static java.time.Duration |
DEFAULT_STALE_AFTER
The default value for
staleAfter(Duration) . |
static java.time.Duration |
DEFAULT_STATUS_POLL_INTERVAL
The default value for
statusPollInterval(Duration) . |
static int |
DEFAULT_USER_CACHE_SIZE
The default value for
userCacheSize(int) . |
static java.time.Duration |
DEFAULT_USER_CACHE_TIME
The default value for
userCacheTime(Duration) . |
Constructor and Description |
---|
BigSegmentsConfigurationBuilder(ComponentConfigurer<BigSegmentStore> storeConfigurer)
Creates a new builder for Big Segments configuration.
|
Modifier and Type | Method and 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.
|
public static final int DEFAULT_USER_CACHE_SIZE
userCacheSize(int)
.public static final java.time.Duration DEFAULT_USER_CACHE_TIME
userCacheTime(Duration)
.public static final java.time.Duration DEFAULT_STATUS_POLL_INTERVAL
statusPollInterval(Duration)
.public static final java.time.Duration DEFAULT_STALE_AFTER
staleAfter(Duration)
.public BigSegmentsConfigurationBuilder(ComponentConfigurer<BigSegmentStore> storeConfigurer)
storeConfigurer
- the factory implementation for the specific data store typepublic BigSegmentsConfigurationBuilder userCacheSize(int userCacheSize)
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)
.
userCacheSize
- the maximum number of user states to cacheDEFAULT_USER_CACHE_SIZE
public BigSegmentsConfigurationBuilder userCacheTime(java.time.Duration userCacheTime)
See userCacheSize(int)
for more about this cache. A higher value for
userCacheTime
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.
userCacheTime
- the cache TTL (a value of null, or a negative value will be changed to
DEFAULT_USER_CACHE_TIME
DEFAULT_USER_CACHE_TIME
public BigSegmentsConfigurationBuilder statusPollInterval(java.time.Duration statusPollInterval)
statusPollInterval
- the status polling interval (a null, zero, or negative value will
be changed to DEFAULT_STATUS_POLL_INTERVAL
)DEFAULT_STATUS_POLL_INTERVAL
public BigSegmentsConfigurationBuilder staleAfter(java.time.Duration staleAfter)
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 its stale
property, and any EvaluationReason
generated from a feature
flag that references a Big Segment will have a EvaluationReason.BigSegmentsStatus
of
EvaluationReason.BigSegmentsStatus.STALE
.
staleAfter
- the time limit for marking the data as stale (a null, zero, or negative
value will be changed to DEFAULT_STALE_AFTER
)DEFAULT_STALE_AFTER
public BigSegmentsConfiguration build(ClientContext context)
ComponentConfigurer
build
in interface ComponentConfigurer<BigSegmentsConfiguration>
context
- provides configuration properties and other components from the current
SDK client instance