Interface ReadThroughCache<K,​V>

  • Type Parameters:
    K - the type of the cache key
    V - the type of the cache value
    All Known Implementing Classes:
    ReadThroughAtlassianCache, ReadThroughEntityCache

    public interface ReadThroughCache<K,​V>
    A simple cache interface that supports the use of read-through operations.
    Since:
    7.5
    • Method Detail

      • get

        default V get​(K cacheKey,
                      Supplier<V> delegateLoader)
        Retrieve the value for the given key. If the value is in the cache this will be returned, else the given delegate will be called to retrieve the value. If the delegate returns a value, it will be placed in the cache and returned, else nothing will be placed in the cache and Optional.empty() will be returned.
        Parameters:
        cacheKey - the key to resolve in the cache
        delegateLoader - A Supplier which will be called if there is no value in the cache (may return null).
        Returns:
        the cached value, or the value which was loaded from the supplier (may be null)
      • get

        V get​(K cacheKey,
              Supplier<V> delegateLoader,
              Predicate<V> valueTester)
        Retrieve the value for the given key. If the value is in the cache this will be returned, else the given delegate will be called to retrieve the value. If the delegate returns a value, and if it passes the given filter, it will be placed in the cache and returned. If the filter rejects the value, nothing will be placed in the cache but the value will be returned from the method.
        Parameters:
        cacheKey - the key to resolve in the cache
        delegateLoader - A Supplier which will be called if there is no value in the cache (may return null).
        valueTester - A Predicate that will be used to test the validity of any value in the cache or loaded from the supplier
        Returns:
        the cached value, or the value which was loaded from the supplier (may be null)
      • getBulk

        Map<K,​V> getBulk​(Set<K> cacheKeys,
                               Function<Set<K>,​Map<K,​V>> delegateLoader)
        Retrieves multiple values for the given keys. Any entries not already present in the cache will be supplied via the delegate loader.
      • remove

        void remove​(K cacheKey)
        Removs the cache entry for the given key.
      • removeAll

        void removeAll()
        Removes all cache entries.