Class DynamicMetadataCacheBuilderSpec<IdentifierType,​MetadataType>

  • Type Parameters:
    IdentifierType - The metadata identifier type.
    MetadataType - the metadata type.
    All Implemented Interfaces:
    MetadataCacheBuilderSpec<IdentifierType,​MetadataType>

    public class DynamicMetadataCacheBuilderSpec<IdentifierType,​MetadataType>
    extends BaseMetadataCacheBuilderSpec<IdentifierType,​MetadataType>
    implements MetadataCacheBuilderSpec<IdentifierType,​MetadataType>
    A specification for building a dynamic read-through metadata cache.
    • Field Detail

      • fetchStrategy

        @Nullable
        private Function<CriteriaSet,​MetadataType> fetchStrategy
        The function to use to fetch metadata if either none exists, or the existing is stale.
      • maxCacheDuration

        @Nonnull
        private Duration maxCacheDuration
        Maximum cache duration.
      • minCacheDuration

        @Nonnull
        private Duration minCacheDuration
        Minimum cache duration.
      • maxIdleEntityData

        @Nullable
        private Duration maxIdleEntityData
        The maximum idle time for which the cache will keep data for before it is removed.
      • cleanupTaskInterval

        @Nonnull
        private Duration cleanupTaskInterval
        The interval at which the cleanup task should run.
      • removeIdleEntityData

        private boolean removeIdleEntityData
        Flag indicating whether idle entity data should be removed.
      • initialCleanupTaskDelay

        @Nonnull
        private Duration initialCleanupTaskDelay
        The initial cleanup task delay.
    • Constructor Detail

      • DynamicMetadataCacheBuilderSpec

        protected DynamicMetadataCacheBuilderSpec()
        Constructor.
    • Method Detail

      • getMaxCacheDuration

        @Nonnull
        protected Duration getMaxCacheDuration()
        Get the maximum cache duration for metadata.

        Defaults to: 8 hours.

        Returns:
        the maximum cache duration
      • setMaxCacheDuration

        public void setMaxCacheDuration​(@Nonnull
                                        Duration duration)
        Set the maximum cache duration for metadata.

        Defaults to: 8 hours.

        Parameters:
        duration - the maximum cache duration
      • getMinCacheDuration

        @Nonnull
        protected Duration getMinCacheDuration()
        Get the minimum cache duration for metadata.

        Defaults to: 10 minutes.

        Returns:
        the minimum cache duration
      • setMinCacheDuration

        public void setMinCacheDuration​(@Nonnull
                                        Duration duration)
        Set the minimum cache duration for metadata.

        Defaults to: 10 minutes.

        Parameters:
        duration - the minimum cache duration
      • setRemoveIdleEntityData

        public void setRemoveIdleEntityData​(boolean flag)
        Set the flag indicating whether idle entity data should be removed.
        Parameters:
        flag - true if idle entity data should be removed, false otherwise
      • isRemoveIdleEntityData

        protected boolean isRemoveIdleEntityData()
        Should idle metadata be removed?
        Returns:
        if idle metadata should be resolved.
      • setMetadataExpirationTimeStrategy

        public void setMetadataExpirationTimeStrategy​(@Nonnull
                                                      Function<ExpirationTimeContext<MetadataType>,​Instant> strategy)
        Set the metadata expiration time strategy.
        Parameters:
        strategy - the strategy.
      • getCleanupTaskInterval

        @Nonnull
        protected Duration getCleanupTaskInterval()
        Get the interval at which the cleanup task should run.

        Defaults to: 30 minutes.

        Returns:
        return the interval
      • setCleanupTaskInterval

        public void setCleanupTaskInterval​(@Nonnull
                                           Duration interval)
        Set the interval at which the cleanup task should run.

        Defaults to: 30 minutes.

        Parameters:
        interval - the interval to set
      • setFetchStrategy

        public void setFetchStrategy​(@Nonnull
                                     Function<CriteriaSet,​MetadataType> strategy)
        Set the metadata fetching strategy.
        Parameters:
        strategy - the strategy to use.
      • getFetchStrategy

        @Nullable
        protected Function<CriteriaSet,​MetadataType> getFetchStrategy()
        Get the metadata fetching strategy.
        Returns:
        the fetching strategy.
      • getMaxIdleEntityData

        @Nonnull
        protected Duration getMaxIdleEntityData()
        Get the maximum idle time for which the resolver will keep data for before it is removed.

        Defaults to: 8 hours.

        Returns:
        return the maximum idle time
      • setMaxIdleEntityData

        public void setMaxIdleEntityData​(@Nonnull
                                         Duration max)
        Set the maximum idle time for which the resolver will keep data for before it is removed.

        Defaults to: 8 hours.

        Parameters:
        max - the maximum entity data idle time
      • getInitialCleanupTaskDelay

        @Nonnull
        protected Duration getInitialCleanupTaskDelay()
        Get the initial cleanup task delay.
        Returns:
        Returns the initialCleanupTaskDelay.
      • setInitialCleanupTaskDelay

        public void setInitialCleanupTaskDelay​(@Nonnull
                                               Duration delay)
        Set the initial cleanup task delay.
        Parameters:
        delay - The initialCleanupTaskDelay to set.