Class CacheProxy<K,V>
java.lang.Object
com.github.benmanes.caffeine.jcache.CacheProxy<K,V>
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<Cache.Entry<K,,V>> Cache<K,V>
- Direct Known Subclasses:
LoadingCacheProxy
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumprotected static final classNested classes/interfaces inherited from interface javax.cache.Cache
Cache.Entry<K,V> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Optional<CacheLoader<K, V>> protected final EventDispatcher<K, V> protected final Executorprotected final Set<CompletableFuture<?>> protected final JCacheStatisticsMXBeanprotected final Ticker -
Constructor Summary
ConstructorsConstructorDescriptionCacheProxy(String name, Executor executor, CacheManager cacheManager, CaffeineConfiguration<K, V> configuration, Cache<K, @Nullable Expirable<V>> cache, EventDispatcher<K, V> dispatcher, Optional<CacheLoader<K, V>> cacheLoader, ExpiryPolicy expiry, Ticker ticker, JCacheStatisticsMXBean statistics) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()voidclose()booleancontainsKey(K key) Returns a deep copy of the map if value-based caching is enabled.protected final <T> TReturns a copy of the value if value-based caching is enabled.protected final VReturns a copy of the value if value-based caching is enabled.protected final longReturns the current time in milliseconds.voidderegisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) getAndFilterExpiredEntries(Set<? extends K> keys, boolean updateAccessTime) Returns all of the mappings present, expiring as required, and optionally updates their access expiry time.getAndRemove(K key) getAndReplace(K key, V value) <C extends Configuration<K,V>>
CgetConfiguration(Class<C> clazz) getName()protected final longgetWriteExpireTimeMillis(boolean created) Returns the time when the entry will expire.<T> @Nullable T<T> Map<K, EntryProcessorResult<T>> booleanisClosed()iterator()voidloadAll(Set<? extends K> keys, boolean replaceExistingValues, CompletionListener completionListener) protected static longnanosToMillis(long nanos) Returns the nanosecond time in milliseconds.voidvoidbooleanputIfAbsent(K key, V value) protected CacheProxy.PutResult<V> putNoCopyOrAwait(K key, V value, boolean publishToWriter) Associates the specified value with the specified key in the cache.voidregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) booleanbooleanvoidvoidbooleanbooleanprotected final voidChecks that the cache is not closed.protected final voidsetAccessExpireTime(K key, Expirable<?> expirable, long currentTimeMillis) Sets the access expiration time.<T> TMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
cache
-
cacheLoader
-
inFlight
-
statistics
-
dispatcher
-
executor
-
ticker
-
-
Constructor Details
-
CacheProxy
public CacheProxy(String name, Executor executor, CacheManager cacheManager, CaffeineConfiguration<K, V> configuration, Cache<K, @Nullable Expirable<V>> cache, EventDispatcher<K, V> dispatcher, Optional<CacheLoader<K, V>> cacheLoader, ExpiryPolicy expiry, Ticker ticker, JCacheStatisticsMXBean statistics)
-
-
Method Details
-
containsKey
- Specified by:
containsKeyin interfaceCache<K,V>
-
get
-
getAll
-
getAndFilterExpiredEntries
-
loadAll
-
put
-
getAndPut
-
putNoCopyOrAwait
@CanIgnoreReturnValue protected CacheProxy.PutResult<V> putNoCopyOrAwait(K key, V value, boolean publishToWriter) Associates the specified value with the specified key in the cache.- Parameters:
key- key with which the specified value is to be associatedvalue- value to be associated with the specified keypublishToWriter- if the writer should be notified- Returns:
- the old value
-
putAll
-
putIfAbsent
-
remove
-
remove
-
getAndRemove
-
replace
-
replace
-
getAndReplace
-
removeAll
-
removeAll
-
clear
-
getConfiguration
- Specified by:
getConfigurationin interfaceCache<K,V>
-
invoke
-
invokeAll
-
getName
-
getCacheManager
- Specified by:
getCacheManagerin interfaceCache<K,V>
-
isClosed
-
close
-
unwrap
-
registerCacheEntryListener
public void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) - Specified by:
registerCacheEntryListenerin interfaceCache<K,V>
-
deregisterCacheEntryListener
public void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) - Specified by:
deregisterCacheEntryListenerin interfaceCache<K,V>
-
iterator
-
requireNotClosed
protected final void requireNotClosed()Checks that the cache is not closed. -
copyOf
Returns a copy of the value if value-based caching is enabled.- Type Parameters:
T- the type of object being copied- Parameters:
object- the object to be copied- Returns:
- a copy of the object if storing by value or the same instance if by reference
-
copyValue
-
copyMap
-
currentTimeMillis
protected final long currentTimeMillis()Returns the current time in milliseconds. -
nanosToMillis
protected static long nanosToMillis(long nanos) Returns the nanosecond time in milliseconds. -
setAccessExpireTime
-
getWriteExpireTimeMillis
protected final long getWriteExpireTimeMillis(boolean created) Returns the time when the entry will expire.- Parameters:
created- if the write operation is an insert or an update- Returns:
- the time when the entry will expire, zero if it should expire immediately, Long.MIN_VALUE if it should not be changed, or Long.MAX_VALUE if eternal
-