Interface Cache

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <T extends Cache>
      T
      as​(Class<T> type)
      Returns this cache as an instance of the provided type if possible.
      <K,​V>
      io.smallrye.mutiny.Uni<V>
      get​(K key, Function<K,​V> valueLoader)
      Returns a lazy asynchronous action that will emit the cache value identified by key, obtaining that value from valueLoader if necessary.
      Object getDefaultKey()
      Returns the unique and immutable default key for the current cache.
      String getName()
      Returns the cache name.
      io.smallrye.mutiny.Uni<Void> invalidate​(Object key)
      Removes the cache entry identified by key from the cache.
      io.smallrye.mutiny.Uni<Void> invalidateAll()
      Removes all entries from the cache.
    • Method Detail

      • getName

        String getName()
        Returns the cache name.
        Returns:
        cache name
      • getDefaultKey

        Object getDefaultKey()
        Returns the unique and immutable default key for the current cache. This key is used by the annotations caching API when a no-args method annotated with CacheResult or CacheInvalidate is invoked. It can also be used with the programmatic caching API.
        Returns:
        default cache key
      • get

        <K,​V> io.smallrye.mutiny.Uni<V> get​(K key,
                                                  Function<K,​V> valueLoader)
        Returns a lazy asynchronous action that will emit the cache value identified by key, obtaining that value from valueLoader if necessary.
        Type Parameters:
        K - cache key type
        V - cache value type
        Parameters:
        key - cache key
        valueLoader - function used to compute a cache value if key is not already associated with a value
        Returns:
        a lazy asynchronous action that will emit a cache value
        Throws:
        NullPointerException - if the key is null
        CacheException - if an exception is thrown during a cache value computation
      • invalidate

        io.smallrye.mutiny.Uni<Void> invalidate​(Object key)
        Removes the cache entry identified by key from the cache. If the key does not identify any cache entry, nothing will happen.
        Parameters:
        key - cache key
        Throws:
        NullPointerException - if the key is null
      • invalidateAll

        io.smallrye.mutiny.Uni<Void> invalidateAll()
        Removes all entries from the cache.
      • as

        <T extends Cache> T as​(Class<T> type)
        Returns this cache as an instance of the provided type if possible.
        Returns:
        cache instance of the provided type
        Throws:
        IllegalStateException - if this cache is not an instance of type