Class BatchMetadataCacheBuilderSpec<IdentifierType,​MetadataType>

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

    public class BatchMetadataCacheBuilderSpec<IdentifierType,​MetadataType>
    extends BaseMetadataCacheBuilderSpec<IdentifierType,​MetadataType>
    implements MetadataCacheBuilderSpec<IdentifierType,​MetadataType>
    A specification for building a batch based read-ahead metadata cache.
    • Field Detail

      • parsingStrategy

        @Nullable
        private Function<byte[],​List<MetadataType>> parsingStrategy
        How to parse the loaded metadata from the loadingStrategy into a usable metadatatype. Applicable for BatchMetadataCache types.
      • maxRefreshDelay

        @Nonnull
        @Positive
        private Duration maxRefreshDelay
        Refresh interval used when metadata does not contain any validUntil or cacheDuration information. Default value: 4 hours
      • minRefreshDelay

        @Nonnull
        @Positive
        private Duration minRefreshDelay
        Floor, in milliseconds, for the refresh interval. Default value: 5 minutes
      • matchOnIdentifierRequired

        @Nonnull
        private boolean matchOnIdentifierRequired
        Is a match based on an identifier required? If not, all known metadata will be returned. Defaults to true - a match on identifier is required.
      • sourceMetadataExpiryStrategy

        @Nullable
        private Function<byte[],​Instant> sourceMetadataExpiryStrategy
        Determine the expiration time of the source batch loaded metadata.
      • sourceMetadataValidPredicate

        @Nonnull
        private Predicate<byte[]> sourceMetadataValidPredicate
        Is the raw metadata bytes from the source valid?
    • Constructor Detail

      • BatchMetadataCacheBuilderSpec

        public BatchMetadataCacheBuilderSpec()
        Constructor.
    • Method Detail

      • setSourceMetadataValidPredicate

        public void setSourceMetadataValidPredicate​(@Nonnull
                                                    Predicate<byte[]> predicate)
        Set the predicate which determines if the source metadata is valid or not.
        Parameters:
        predicate - the predicate.
      • getSourceMetadataValidPredicate

        @Nonnull
        protected Predicate<byte[]> getSourceMetadataValidPredicate()
        Get the predicate which determines if the source metadata is valid or not.
        Returns:
        the predicate.
      • setSourceMetadataExpiryStrategy

        public void setSourceMetadataExpiryStrategy​(@Nonnull
                                                    Function<byte[],​Instant> strategy)
        Set a strategy to find the metadata expiry date from a source metadata document as bytes.
        Parameters:
        strategy - the strategy.
      • getSourceMetadataExpiryStrategy

        @Nullable
        protected Function<byte[],​Instant> getSourceMetadataExpiryStrategy()
        Get the source metadata expiry date strategy.
        Returns:
        the strategy.
      • setMatchRequired

        public void setMatchRequired​(boolean required)
        Set if a match on identifier is required in order to return results. If false and there are no identifiers in the criteria to match on, all cached entries will be returned.
        Parameters:
        required - does the metadata lookup need to match the given criteria.
      • isMatchOnIdentifierRequired

        public boolean isMatchOnIdentifierRequired()
        Get if an identifier criteria match is required.
        Returns:
        is an identifier criteria match required.
      • getMinRefreshDelay

        @Nonnull
        protected Duration getMinRefreshDelay()
        Get the min delay to wait before refreshing metadata.
        Returns:
        the min delay.
      • getMaxRefreshDelay

        @Nonnull
        protected Duration getMaxRefreshDelay()
        Get the max delay to wait before refreshing metadata.
        Returns:
        the max delay.
      • setMinRefreshDelay

        public void setMinRefreshDelay​(@Positive @Nonnull
                                       Duration delay)
        Sets the minimum amount of time between refreshes.
        Parameters:
        delay - minimum amount of time between refreshes
      • setMaxRefreshDelay

        public void setMaxRefreshDelay​(@Positive @Nonnull
                                       Duration delay)
        Sets the maximum amount of time between refresh intervals.
        Parameters:
        delay - maximum amount of time, in milliseconds, between refresh intervals
      • setParsingStrategy

        public void setParsingStrategy​(@Nonnull
                                       Function<byte[],​List<MetadataType>> strategy)
        Set he raw batch metadata to metadata type parsing strategy.
        Parameters:
        strategy - the parsing strategy.
      • getParsingStrategy

        @Nullable
        protected Function<byte[],​List<MetadataType>> getParsingStrategy()
        Get the raw batch metadata to metadata type parsing strategy.
        Returns:
        the parsing strategy.
      • setLoadingStrategy

        public void setLoadingStrategy​(@Nonnull
                                       LoadingStrategy strategy)
        Set the batch metadata loading strategy, applies to the BatchMetadataCache type.
        Parameters:
        strategy - the strategy to set.
      • getLoadingStrategy

        @Nullable
        protected LoadingStrategy getLoadingStrategy()
        Get the batch metadata loading strategy.
        Returns:
        the strategy.