Class CachePersistencyOptions


  • @ProviderType
    public final class CachePersistencyOptions
    extends Object
    Cache persistency options configure entry store requirements while read or write operations in CacheAdapter. Options specify cache response refresh interval, storage time and automatical extension of storage time per stored entry. See also CacheStrategy.
    • Constructor Detail

      • CachePersistencyOptions

        public CachePersistencyOptions​(int refreshInterval,
                                       int storageTime,
                                       boolean extendStorageTimeOnGet)
        Default constructor for complete initialization of cache persistency and transient options.
        Parameters:
        refreshInterval - cached response refresh interval in seconds
        storageTime - time of response storing in seconds
        extendStorageTimeOnGet - true if storage time should be extended
      • CachePersistencyOptions

        public CachePersistencyOptions​(int refreshInterval,
                                       int storageTime,
                                       boolean extendStorageTimeOnGet,
                                       boolean shouldUseTransientCaches)
        Default constructor for complete initialization of cache persistency and transient options.
        Parameters:
        refreshInterval - cached response refresh interval in seconds
        storageTime - time of response storing in seconds
        extendStorageTimeOnGet - true if storage time should be extended
        shouldUseTransientCaches - true if transient cache adapters should be enabled, false if disabled
    • Method Detail

      • createPersistentAndTimeToLive

        public static CachePersistencyOptions createPersistentAndTimeToLive​(int refreshInterval,
                                                                            int storageTime)
        Creates caching options specifying cache refresh interval and storing time per entry without next extension of storing time.
        Parameters:
        refreshInterval - cached response refresh interval in seconds
        storageTime - time of response storing in seconds
        Returns:
        persistent and transient caching options without storage time extension
      • createPersistentAndTimeToIdle

        public static CachePersistencyOptions createPersistentAndTimeToIdle​(int refreshInterval,
                                                                            int storageTime)
        Creates caching options specifying cache refresh interval and storing time per entry with next extension of storing time.
        Parameters:
        refreshInterval - cached response refresh interval in seconds
        storageTime - time of response storing in seconds
        Returns:
        persistent and transient caching options with storage time extension
      • createTransient

        public static CachePersistencyOptions createTransient​(int refreshInterval)
        Creates caching options specifying cache refresh interval. No entry storing time is declared.
        Parameters:
        refreshInterval - cached response refresh interval in seconds
        Returns:
        transient caching options
      • getRefreshInterval

        public int getRefreshInterval()
        Defines the time (in seconds) after which a cached response for the given request should be considered stale. After this time, the JsonPipeline will try to fetch a fresh response from the origin server, and will only use the stale content from cache as a fallback if this attempt fails.
        Returns:
        the duration in seconds until a cached response is considered stale, and should be re-validated
      • getStorageTime

        public int getStorageTime()
        Defines the time (in seconds) for which the response to the given request should be at least stored in the cache. The actual storage time can be longer if isExtendStorageTimeOnGet() or for other technical reasons.
        Returns:
        the minimum duration in seconds to keep the response in the cache
      • isExtendStorageTimeOnGet

        public boolean isExtendStorageTimeOnGet()
        Determines whether to automatically extend the storage time (to the duration returned by getStorageTime() whenever a response was successfully retrieved from cache, resulting in a "time-to-idle" cache behavior, where the total storage time is unlimited, but instead data is kept in the cache as long as it is still being requested.
        Returns:
        true if the storage value for this request should be extended on every cache hit
      • isCacheable

        public boolean isCacheable()
        Checks if the entry should be cached.
        Returns:
        true if refresh interval is specified (more than 0).
      • isPersistent

        @Deprecated
        public boolean isPersistent()
        Deprecated.
        Use shouldUsePersistentCaches() instead of deprecated isPersistent().
        Check if theentry should be cached by persistent cache implementation. A configuration to enable or disable cache operations by persistent adapters.
        Returns:
        true if persistent adapters should be supported (storage time is specified, more than 0).
      • shouldUsePersistentCaches

        public boolean shouldUsePersistentCaches()
        Check if the entry should be cached by persistent cache implementation. A configuration to enable or disable cache operations by persistent adapters.
        Returns:
        true if persistent adapters should be supported (storage time is specified, more than 0).
      • shouldUseTransientCaches

        public boolean shouldUseTransientCaches()
        Check if the entry should be cached by transient cache implementation. A configuration to enable or disable cache operations by transient adapters.
        Returns:
        true if transient adapter should be supported