Top Description Inners Fields Constructors Methods
com.github.benmanes.caffeine.cache

pack-priv final Class Async

extends Object
Class Inheritance
Annotations
@SuppressWarnings:serial
Static Imports
com.github.benmanes.caffeine.cache.BoundedLocalCache.MAXIMUM_EXPIRY, java.util.Objects.requireNonNull

Static utility methods and classes pertaining to asynchronous operations.
Author
[email protected] (Ben Manes)

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
Async.AsyncEvictionListener<K, V>

An eviction listener that forwards the value stored in a CompletableFuture to the user-supplied eviction listener.

pack-priv static class
Async.AsyncExpiry<K, V>

An expiry for asynchronous computations.

pack-priv static class
Async.AsyncRemovalListener<K, V>

A removal listener that asynchronously forwards the value stored in a CompletableFuture if successful to the user-supplied removal listener.

pack-priv static class
Async.AsyncWeigher<K, V>

A weigher for asynchronous computations.

Field Summary

Modifier and TypeField and Description
pack-priv static final long

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static <V> @Nullable V
getIfReady(@Nullable CompletableFuture<V> future)

Returns the current value or null if either not done or failed.

pack-priv static <V> @Nullable V
getWhenSuccessful(@Nullable CompletableFuture<V> future)

Returns the value when completed successfully or null if failed.

pack-priv static boolean
isReady(@Nullable CompletableFuture<?> future)

Returns if the future has successfully completed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ASYNC_EXPIRYback to summary
pack-priv static final long ASYNC_EXPIRY

Constructor Detail

Asyncback to summary
private Async()

Method Detail

getIfReadyback to summary
pack-priv static <V> @Nullable V getIfReady(@Nullable CompletableFuture<V> future)

Returns the current value or null if either not done or failed.

Annotations
@SuppressWarnings:NullAway
getWhenSuccessfulback to summary
pack-priv static <V> @Nullable V getWhenSuccessful(@Nullable CompletableFuture<V> future)

Returns the value when completed successfully or null if failed.

isReadyback to summary
pack-priv static boolean isReady(@Nullable CompletableFuture<?> future)

Returns if the future has successfully completed.

com.github.benmanes.caffeine.cache back to summary

pack-priv final Class Async.AsyncEvictionListener<K, V>

extends Object
implements RemovalListener<K, CompletableFuture<V>>, Serializable
Class Inheritance
  • java.lang.Object
  • com.github.benmanes.caffeine.cache.Async.AsyncEvictionListener
All Implemented Interfaces
java.io.Serializable, com.github.benmanes.caffeine.cache.RemovalListener

An eviction listener that forwards the value stored in a CompletableFuture to the user-supplied eviction listener.

Field Summary

Modifier and TypeField and Description
pack-priv final RemovalListener<K, V>
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
pack-priv Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
pack-priv final RemovalListener<K, V> delegate
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

AsyncEvictionListenerback to summary
pack-priv AsyncEvictionListener(RemovalListener<K, V> delegate)

Method Detail

onRemovalback to summary
public void onRemoval(@Nullable K key, @Nullable CompletableFuture<V> future, RemovalCause cause)
Annotations
@Override
writeReplaceback to summary
pack-priv Object writeReplace()
com.github.benmanes.caffeine.cache back to summary

pack-priv final Class Async.AsyncExpiry<K, V>

extends Object
implements Expiry<K, CompletableFuture<V>>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, com.github.benmanes.caffeine.cache.Expiry

An expiry for asynchronous computations. When the value is being loaded this expiry returns ASYNC_EXPIRY to indicate that the entry should not be evicted due to an expiry constraint. If the value is computed successfully then the entry must be reinserted so that the expiration is updated and the expiration timeouts reflect the value once present. The duration's maximum range is reserved to coordinate with the asynchronous life cycle.

Field Summary

Modifier and TypeField and Description
pack-priv final Expiry<? super K, ? super V>
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv
AsyncExpiry(Expiry<? super K, ? super V> delegate)

Method Summary

Modifier and TypeMethod and Description
public long
expireAfterCreate(K
the key represented by this entry
key
,
CompletableFuture<V>
the value represented by this entry
future
,
long
the current time, in nanoseconds
currentTime
)

Implements com.github.benmanes.caffeine.cache.Expiry.expireAfterCreate.

Specifies that the entry should be automatically removed from the cache once the duration has elapsed after the entry's creation.
public long
expireAfterRead(K key, CompletableFuture<V> future, long currentTime, long currentDuration)

public long
expireAfterUpdate(K key, CompletableFuture<V> future, long currentTime, long currentDuration)

pack-priv Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
pack-priv final Expiry<? super K, ? super V> delegate
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

AsyncExpiryback to summary
pack-priv AsyncExpiry(Expiry<? super K, ? super V> delegate)

Method Detail

expireAfterCreateback to summary
public long expireAfterCreate(K key, CompletableFuture<V> future, long currentTime)

Implements com.github.benmanes.caffeine.cache.Expiry.expireAfterCreate.

Doc from com.github.benmanes.caffeine.cache.Expiry.expireAfterCreate.

Specifies that the entry should be automatically removed from the cache once the duration has elapsed after the entry's creation. To indicate no expiration, an entry may be given an excessively long period, such as Long#MAX_VALUE.

Note

The currentTime is supplied by the configured Ticker and by default does not relate to system or wall-clock time. When calculating the duration based on a timestamp, the current time should be obtained independently.

Parameters
key:K

the key represented by this entry

future:CompletableFuture<V>

the value represented by this entry

currentTime:long

the current time, in nanoseconds

Returns:long

the length of time before the entry expires, in nanoseconds

Annotations
@Override
expireAfterReadback to summary
public long expireAfterRead(K key, CompletableFuture<V> future, long currentTime, long currentDuration)
Annotations
@Override
expireAfterUpdateback to summary
public long expireAfterUpdate(K key, CompletableFuture<V> future, long currentTime, long currentDuration)
Annotations
@Override
writeReplaceback to summary
pack-priv Object writeReplace()
com.github.benmanes.caffeine.cache back to summary

pack-priv final Class Async.AsyncRemovalListener<K, V>

extends Object
implements RemovalListener<K, CompletableFuture<V>>, Serializable
Class Inheritance
  • java.lang.Object
  • com.github.benmanes.caffeine.cache.Async.AsyncRemovalListener
All Implemented Interfaces
java.io.Serializable, com.github.benmanes.caffeine.cache.RemovalListener

A removal listener that asynchronously forwards the value stored in a CompletableFuture if successful to the user-supplied removal listener.

Field Summary

Modifier and TypeField and Description
pack-priv final RemovalListener<K, V>
pack-priv final Executor
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv
AsyncRemovalListener(RemovalListener<K, V> delegate, Executor executor)

Method Summary

Modifier and TypeMethod and Description
public void
pack-priv Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
pack-priv final RemovalListener<K, V> delegate
executorback to summary
pack-priv final Executor executor
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

AsyncRemovalListenerback to summary
pack-priv AsyncRemovalListener(RemovalListener<K, V> delegate, Executor executor)

Method Detail

onRemovalback to summary
public void onRemoval(@Nullable K key, @Nullable CompletableFuture<V> future, RemovalCause cause)
Annotations
@Override
@SuppressWarnings:FutureReturnValueIgnored
writeReplaceback to summary
pack-priv Object writeReplace()
com.github.benmanes.caffeine.cache back to summary

pack-priv final Class Async.AsyncWeigher<K, V>

extends Object
implements Weigher<K, CompletableFuture<V>>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, com.github.benmanes.caffeine.cache.Weigher

A weigher for asynchronous computations. When the value is being loaded this weigher returns 0 to indicate that the entry should not be evicted due to a size constraint. If the value is computed successfully then the entry must be reinserted so that the weight is updated and the expiration timeouts reflect the value once present. This can be done safely using Map#replace(Object, Object, Object).

Field Summary

Modifier and TypeField and Description
pack-priv final Weigher<K, V>
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv
AsyncWeigher(Weigher<K, V> delegate)

Method Summary

Modifier and TypeMethod and Description
public int
weigh(K
the key to weigh
key
,
CompletableFuture<V>
the value to weigh
future
)

Implements com.github.benmanes.caffeine.cache.Weigher.weigh.

Returns the weight of a cache entry.
pack-priv Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
pack-priv final Weigher<K, V> delegate
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

AsyncWeigherback to summary
pack-priv AsyncWeigher(Weigher<K, V> delegate)

Method Detail

weighback to summary
public int weigh(K key, CompletableFuture<V> future)

Implements com.github.benmanes.caffeine.cache.Weigher.weigh.

Doc from com.github.benmanes.caffeine.cache.Weigher.weigh.

Returns the weight of a cache entry. There is no unit for entry weights; rather they are simply relative to each other.

Parameters
key:K

the key to weigh

future:CompletableFuture<V>

the value to weigh

Returns:int

the weight of the entry; must be non-negative

Annotations
@Override
writeReplaceback to summary
pack-priv Object writeReplace()