Class LfuCache<K,V>

java.lang.Object
akka.http.caching.scaladsl.Cache<K,V>
akka.http.caching.LfuCache<K,V>
All Implemented Interfaces:
Cache<K,V>

public class LfuCache<K,V> extends Cache<K,V>
INTERNAL API
  • Constructor Summary

    Constructors
    Constructor
    Description
    LfuCache(com.github.benmanes.caffeine.cache.AsyncCache<K,V> store)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    scala.concurrent.Future<V>
    apply(K key, scala.Function0<scala.concurrent.Future<V>> genValue)
    Returns either the cached Future for the given key or evaluates the given value generating function producing a Future[V].
    void
    Clears the cache by removing all entries.
    static <K, V> Cache<K,V>
    create(akka.actor.ActorSystem system)
    Java API Creates a new LfuCache using configuration of the system, with optional expiration depending on whether a non-zero and finite timeToLive and/or timeToIdle is set or not.
    static <K, V> Cache<K,V>
    Java API Creates a new LfuCache, with optional expiration depending on whether a non-zero and finite timeToLive and/or timeToIdle is set or not.
    scala.Option<scala.concurrent.Future<V>>
    get(K key)
    Retrieves the future instance that is currently in the cache for the given key.
    scala.concurrent.Future<V>
    getOrLoad(K key, scala.Function1<K,scala.concurrent.Future<V>> loadValue)
    Returns either the cached Future for the given key, or applies the given value loading function on the key, producing a Future[V].
    scala.collection.immutable.Set<K>
    Returns the set of keys in the cache, in no particular order Should return in roughly constant time.
    scala.concurrent.Future<V>
    put(K key, scala.concurrent.Future<V> mayBeValue, scala.concurrent.ExecutionContext ex)
    Multiple call to put method for the same key may result in a race condition, the value yield by the last successful future for that key will replace any previously cached value.
    void
    remove(K key)
    Removes the cache item for the given key.
    int
    Returns the upper bound for the number of currently cached entries.
    com.github.benmanes.caffeine.cache.AsyncCache<K,V>
     
    toJavaMappingFunction(scala.Function0<scala.concurrent.Future<V>> genValue)
     
    toJavaMappingFunction(scala.Function1<K,scala.concurrent.Future<V>> loadValue)
     

    Methods inherited from class akka.http.caching.scaladsl.Cache

    apply, get, getFuture, getKeys, getOptional, getOrCreateStrict, getOrFulfil

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LfuCache

      public LfuCache(com.github.benmanes.caffeine.cache.AsyncCache<K,V> store)
  • Method Details

    • create

      public static <K, V> Cache<K,V> create(akka.actor.ActorSystem system)
      Java API Creates a new LfuCache using configuration of the system, with optional expiration depending on whether a non-zero and finite timeToLive and/or timeToIdle is set or not.
      Parameters:
      system - (undocumented)
      Returns:
      (undocumented)
    • create

      public static <K, V> Cache<K,V> create(CachingSettings settings)
      Java API Creates a new LfuCache, with optional expiration depending on whether a non-zero and finite timeToLive and/or timeToIdle is set or not.
      Parameters:
      settings - (undocumented)
      Returns:
      (undocumented)
    • toJavaMappingFunction

      public static <K, V> BiFunction<K,Executor,CompletableFuture<V>> toJavaMappingFunction(scala.Function0<scala.concurrent.Future<V>> genValue)
    • toJavaMappingFunction

      public static <K, V> BiFunction<K,Executor,CompletableFuture<V>> toJavaMappingFunction(scala.Function1<K,scala.concurrent.Future<V>> loadValue)
    • store

      public com.github.benmanes.caffeine.cache.AsyncCache<K,V> store()
    • get

      public scala.Option<scala.concurrent.Future<V>> get(K key)
      Description copied from class: Cache
      Retrieves the future instance that is currently in the cache for the given key. Returns None if the key has no corresponding cache entry.
      Specified by:
      get in class Cache<K,V>
      Parameters:
      key - (undocumented)
      Returns:
      (undocumented)
    • apply

      public scala.concurrent.Future<V> apply(K key, scala.Function0<scala.concurrent.Future<V>> genValue)
      Description copied from class: Cache
      Returns either the cached Future for the given key or evaluates the given value generating function producing a Future[V].
      Specified by:
      apply in class Cache<K,V>
      Parameters:
      key - (undocumented)
      genValue - (undocumented)
      Returns:
      (undocumented)
    • put

      public scala.concurrent.Future<V> put(K key, scala.concurrent.Future<V> mayBeValue, scala.concurrent.ExecutionContext ex)
      Multiple call to put method for the same key may result in a race condition, the value yield by the last successful future for that key will replace any previously cached value.
      Specified by:
      put in class Cache<K,V>
      Parameters:
      key - (undocumented)
      mayBeValue - (undocumented)
      ex - (undocumented)
      Returns:
      (undocumented)
    • getOrLoad

      public scala.concurrent.Future<V> getOrLoad(K key, scala.Function1<K,scala.concurrent.Future<V>> loadValue)
      Description copied from class: Cache
      Returns either the cached Future for the given key, or applies the given value loading function on the key, producing a Future[V].
      Specified by:
      getOrLoad in class Cache<K,V>
      Parameters:
      key - (undocumented)
      loadValue - (undocumented)
      Returns:
      (undocumented)
    • remove

      public void remove(K key)
      Description copied from class: Cache
      Removes the cache item for the given key.
      Specified by:
      remove in interface Cache<K,V>
      Specified by:
      remove in class Cache<K,V>
      Parameters:
      key - (undocumented)
    • clear

      public void clear()
      Description copied from class: Cache
      Clears the cache by removing all entries.
      Specified by:
      clear in interface Cache<K,V>
      Specified by:
      clear in class Cache<K,V>
    • keys

      public scala.collection.immutable.Set<K> keys()
      Description copied from class: Cache
      Returns the set of keys in the cache, in no particular order Should return in roughly constant time. Note that this number might not reflect the exact keys of active, unexpired cache entries, since expired entries are only evicted upon next access (or by being thrown out by a capacity constraint).
      Specified by:
      keys in class Cache<K,V>
      Returns:
      (undocumented)
    • size

      public int size()
      Description copied from class: Cache
      Returns the upper bound for the number of currently cached entries. Note that this number might not reflect the exact number of active, unexpired cache entries, since expired entries are only evicted upon next access (or by being thrown out by a capacity constraint).
      Specified by:
      size in interface Cache<K,V>
      Specified by:
      size in class Cache<K,V>
      Returns:
      (undocumented)