Package io.kcache

Interface Cache<K,​V>

    • Method Detail

      • isPersistent

        default boolean isPersistent()
        Whether the cache is persistent.
        Returns:
        whether the cache is persistent
      • configure

        default void configure​(Map<String,​?> configs)
        Configures the cache.
        Specified by:
        configure in interface org.apache.kafka.common.Configurable
      • reset

        void reset()
        Resets the cache, clearing stale data before a sync. This can be used if the leader changes in a cluster.
      • sync

        void sync()
        Syncs (or re-initializes) the cache with the backing store.
      • subCache

        Cache<K,​V> subCache​(K fromKey,
                                  boolean fromInclusive,
                                  K toKey,
                                  boolean toInclusive)
        Returns a view of the portion of this cache whose keys range from fromKey to toKey. If fromKey and toKey are equal, the returned cache is empty unless fromInclusive and toInclusive are both true. The returned cache is backed by this cache, so changes in the returned cache are reflected in this cache, and vice-versa. The returned cache supports all optional cache operations that this cache supports.

        The returned cache will throw an IllegalArgumentException on an attempt to insert a key outside of its range, or to construct a subcache either of whose endpoints lie outside its range.

        Parameters:
        fromKey - low endpoint of the keys in the returned cache; null indicates the beginning
        fromInclusive - true if the low endpoint is to be included in the returned view
        toKey - high endpoint of the keys in the returned cache; null indicates the end
        toInclusive - true if the high endpoint is to be included in the returned view
        Returns:
        a view of the portion of this cache whose keys range from fromKey to toKey
        Throws:
        ClassCastException - if fromKey and toKey cannot be compared to one another using this cache's comparator (or, if the cache has no comparator, using natural ordering). Implementations may, but are not required to, throw this exception if fromKey or toKey cannot be compared to keys currently in the cache.
        IllegalArgumentException - if fromKey is greater than toKey; or if this cache itself has a restricted range, and fromKey or toKey lies outside the bounds of the range
      • range

        KeyValueIterator<K,​V> range​(K fromKey,
                                          boolean fromInclusive,
                                          K toKey,
                                          boolean toInclusive)
        Returns an iterator over the portion of this cache whose keys range from fromKey to toKey. If fromKey and toKey are equal, the returned iterator is empty unless fromInclusive and toInclusive are both true.
        Parameters:
        fromKey - low endpoint of the keys in the returned iterator; null indicates the beginning
        fromInclusive - true if the low endpoint is to be included in the returned view
        toKey - high endpoint of the keys in the returned iterator; null indicates the end
        toInclusive - true if the high endpoint is to be included in the returned view
        Returns:
        an iterator over the portion of this cache whose keys range from fromKey to toKey
        Throws:
        ClassCastException - if fromKey and toKey cannot be compared to one another using this cache's comparator (or, if the cache has no comparator, using natural ordering). Implementations may, but are not required to, throw this exception if fromKey or toKey cannot be compared to keys currently in the cache.
        IllegalArgumentException - if fromKey is greater than toKey; or if this cache itself has a restricted range, and fromKey or toKey lies outside the bounds of the range
      • descendingCache

        Cache<K,​V> descendingCache()
        Returns a reverse order view of the mappings contained in this cache. The descending cache is backed by this cache, so changes to the cache are reflected in the descending cache, and vice-versa. If either cache is modified while an iteration over a collection view of either cache is in progress (except through the iterator's own remove operation), the results of the iteration are undefined.
        Returns:
        a reverse order view of this cache
      • flush

        void flush()
        Flushes the cache.