Enum PersistentDataStoreBuilder.StaleValuesPolicy

    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      EVICT
      Indicates that when the cache TTL expires for an item, it is evicted from the cache.
      REFRESH
      Indicates that the cache should refresh stale values instead of evicting them.
      REFRESH_ASYNC
      Indicates that the cache should refresh stale values asynchronously instead of evicting them.
    • Enum Constant Detail

      • EVICT

        public static final PersistentDataStoreBuilder.StaleValuesPolicy EVICT
        Indicates that when the cache TTL expires for an item, it is evicted from the cache. The next attempt to read that item causes a synchronous read from the underlying data store; if that fails, no value is available. This is the default behavior.
        See Also:
        CacheBuilder.expireAfterWrite(long, TimeUnit)
      • REFRESH

        public static final PersistentDataStoreBuilder.StaleValuesPolicy REFRESH
        Indicates that the cache should refresh stale values instead of evicting them.

        In this mode, an attempt to read an expired item causes a synchronous read from the underlying data store, like EVICT--but if an error occurs during this refresh, the cache will continue to return the previously cached values (if any). This is useful if you prefer the most recently cached feature rule set to be returned for evaluation over the default value when updates go wrong.

        See: CacheBuilder for more specific information on cache semantics. This mode is equivalent to expireAfterWrite.

      • REFRESH_ASYNC

        public static final PersistentDataStoreBuilder.StaleValuesPolicy REFRESH_ASYNC
        Indicates that the cache should refresh stale values asynchronously instead of evicting them.

        This is the same as REFRESH, except that the attempt to refresh the value is done on another thread (using a Executor). In the meantime, the cache will continue to return the previously cached value (if any) in a non-blocking fashion to threads requesting the stale key. Any exception encountered during the asynchronous reload will cause the previously cached value to be retained.

        This setting is ideal to enable when you desire high performance reads and can accept returning stale values for the period of the async refresh. For example, configuring this feature store with a very low cache time and enabling this feature would see great performance benefit by decoupling calls from network I/O.

        See: CacheBuilder for more specific information on cache semantics.

    • Method Detail

      • values

        public static PersistentDataStoreBuilder.StaleValuesPolicy[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (PersistentDataStoreBuilder.StaleValuesPolicy c : PersistentDataStoreBuilder.StaleValuesPolicy.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static PersistentDataStoreBuilder.StaleValuesPolicy valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null