Creates a function which caches the results of fn
in an
com.twitter.cache.FutureCache.
Creates a function which caches the results of fn
in an
com.twitter.cache.FutureCache. Ensures that failed Futures are evicted,
and that interrupting a Future returned to you by this function is safe.
standard for the equivalent Java API.
A com.twitter.cache.FutureCache
backed by a
java.util.concurrent.ConcurrentMap
.
Encodes keys, producing a Cache that takes keys of a different type.
Alias for default which can be called from Java.
The FutureCache object provides the public interface for constructing FutureCaches. Once you've constructed a basic FutureCache, you should almost always wrap it with default. Normal usage looks like:
val fn: K => Future[V] val map = (new java.util.concurrent.ConcurrentHashMap[K, V]()).asScala val cachedFn: K => Future[V] = FutureCache.default(fn, FutureCache.fromMap(map))
We typically recommend that you use
Caffeine
Caches via com.twitter.cache.caffeine.CaffeineCache.