Class BaseMetadataCacheBuilderSpec<IdentifierType,​MetadataType>

    • Field Detail

      • refreshDelayFactor

        @Positive
        private Float refreshDelayFactor
        Factor used to compute when the next refresh interval will occur. Default value: 0.75
      • identifierExtractionStrategy

        @Nullable
        private Function<MetadataType,​IdentifierType> identifierExtractionStrategy
        Strategy used to extract an identifier from the given metadata.
      • criteriaToIdentifierStrategy

        @Nullable
        private Function<CriteriaSet,​IdentifierType> criteriaToIdentifierStrategy
        Map criteria to identifiers to use as keys to the backing store.
      • cacheId

        @Nonnull
        private String cacheId
        An identifier to give the cache this specification builds. Used for logging.
      • metadataBeforeRemovalHook

        @Nullable
        private BiConsumer<List<MetadataType>,​IdentifierType> metadataBeforeRemovalHook
        A hook that is executed just before a cache entry will been removed/invalidated/evicted. The metadata list could be null, the identifier is never null.
      • metadataValidPredicate

        @Nonnull
        private Predicate<MetadataType> metadataValidPredicate
        Is the metadata valid? Defaults to true.
    • Constructor Detail

      • BaseMetadataCacheBuilderSpec

        protected BaseMetadataCacheBuilderSpec()
        Constructor.
    • Method Detail

      • setMetadataValidPredicate

        public void setMetadataValidPredicate​(@Nonnull
                                              Predicate<MetadataType> predicate)
        Set the predicate which determines if a piece of metadata is valid or not.
        Parameters:
        predicate - the predicate.
      • getMetadataValidPredicate

        @Nonnull
        protected Predicate<MetadataType> getMetadataValidPredicate()
        Get the predicate which determines if a piece of metadata is valid or not.
        Returns:
        the predicate.
      • setCacheId

        public void setCacheId​(@Nonnull @NotEmpty
                               String id)
        Set the cache identifier of the cache this specification builds.
        Parameters:
        id - the cache identifier.
      • getCacheId

        @Nonnull
        protected String getCacheId()
        Get the cache identifier.
        Returns:
        the cache identifier.
      • setMetadataBeforeRemovalHook

        public void setMetadataBeforeRemovalHook​(@Nullable
                                                 BiConsumer<List<MetadataType>,​IdentifierType> hook)
        Set a hook to run before a metadata cache entry is removed from the cache.

        The hook is required to gracefully handle null metadata lists.

        Parameters:
        hook - the hook to run.
      • getMetadataBeforeRemovalHook

        @Nullable
        protected BiConsumer<List<MetadataType>,​IdentifierType> getMetadataBeforeRemovalHook()
        Get the metadata before removal hook. Could be null.
        Returns:
        the hook.
      • setMetadataFilterStrategy

        public void setMetadataFilterStrategy​(@Nonnull
                                              BiFunction<MetadataType,​MetadataFilterContext,​MetadataType> strategy)
        Set the metadata filtering strategy.

        Defaults to a no-op strategy.

        Parameters:
        strategy - the metadata filtering strategy.
      • setIdentifierExtractionStrategy

        public void setIdentifierExtractionStrategy​(@Nonnull
                                                    Function<MetadataType,​IdentifierType> strategy)
        Set the identifier extraction strategy.
        Parameters:
        strategy - the strategy to set.
      • getIdentifierExtractionStrategy

        @Nullable
        protected Function<MetadataType,​IdentifierType> getIdentifierExtractionStrategy()
        Get the identifier extraction strategy.
        Returns:
        strategy the strategy.
      • setCriteriaToIdentifierStrategy

        public void setCriteriaToIdentifierStrategy​(@Nonnull
                                                    Function<CriteriaSet,​IdentifierType> strategy)
        Set the criteria set to identifier lookup strategy.
        Parameters:
        strategy - the strategy to set.
      • getCriteriaToIdentifierStrategy

        @Nullable
        protected Function<CriteriaSet,​IdentifierType> getCriteriaToIdentifierStrategy()
        Get the criteria set to identifier lookup strategy.
        Returns:
        strategy the strategy.
      • getRefreshDelayFactor

        @Nonnull
        protected Float getRefreshDelayFactor()
        Gets the delay factor used to compute the next refresh time.

        Defaults to: 0.75.

        Returns:
        delay factor used to compute the next refresh time
      • setRefreshDelayFactor

        public void setRefreshDelayFactor​(@Nonnull
                                          Float factor)
        Sets the delay factor used to compute the next refresh time. The delay must be between 0.0 and 1.0, exclusive.

        Defaults to: 0.75.

        Parameters:
        factor - delay factor used to compute the next refresh time