Class BigSegmentsConfigurationBuilder

    • 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 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.

        Parameters:
        userCacheTime - the cache TTL (a value of null, or a negative value will be changed to DEFAULT_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 to DEFAULT_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 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.

        Parameters:
        staleAfter - the time limit for marking the data as stale (a null, zero, or negative value will be changed to DEFAULT_STALE_AFTER)
        Returns:
        the builder
        See Also:
        DEFAULT_STALE_AFTER