Package org.redisson.jcache
Class JCache<K,V>
java.lang.Object
org.redisson.RedissonObject
org.redisson.jcache.JCache<K,V>
- Type Parameters:
K- keyV- value
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<javax.cache.Cache.Entry<K,,V>> javax.cache.Cache<K,,V> CacheAsync<K,,V> RObject,RObjectAsync
JCache implementation
- Author:
- Nikita Koksharov
-
Nested Class Summary
Nested classes/interfaces inherited from interface javax.cache.Cache
javax.cache.Cache.Entry<K,V> -
Field Summary
Fields inherited from class org.redisson.RedissonObject
codec, commandExecutor, name -
Constructor Summary
ConstructorsConstructorDescriptionJCache(JCacheManager cacheManager, Redisson redisson, String name, JCacheConfiguration<K, V> config, boolean hasOwnRedisson) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()This method empties the cache's contents, without notifying listeners orCacheWriters.voidclose()booleancontainsKey(K key) containsKeyAsync(K key) This method returns a Boolean true/false value, depending on whether theCacheAsynchas a mapping for a key k such that key.equals(k).voidderegisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) getAllAsync(Set<? extends K> keys) This method accepts a set of requested keys and retrieves a collection of entries from theCacheAsync, returning them as aMapof the associated values.getAndPutAsync(K key, V value) This method places the given key and value in the cache.getAndRemove(K key) getAndRemoveAsync(K key) This method atomically removes the entry for a key only if it is currently mapped to some value.getAndReplace(K key, V value) getAndReplaceAsync(K key, V value) This method atomically replaces a given key's value if and only if the key is currently mapped to a value.This method retrieves an entry from the cache.javax.cache.CacheManagergetConfiguration(Class<C> clazz) <T> TinvokeAll(Set<? extends K> keys, javax.cache.processor.EntryProcessor<K, V, T> entryProcessor, Object... arguments) booleanisClosed()iterator()voidloadAll(Set<? extends K> keys, boolean replaceExistingValues, javax.cache.integration.CompletionListener completionListener) voidvoidputAllAsync(Map<? extends K, ? extends V> map) This method copies all of the entries from the given Map to theCacheAsync.This method places the given value V in the cache and associates it with the given key K.booleanputIfAbsent(K key, V value) putIfAbsentAsync(K key, V value) This method places the given key and value in the cache atomically, if the key is not already associated with a value in the cache.voidregisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) booleanbooleanvoidvoidremoveAllAsync(Set<? extends K> keys) This method deletes the entries for the given keys.removeAsync(K key) This method deletes the mapping for a given key from the cache, if it is present.removeAsync(K key, V value) This method atomically removes a key's mapping only if it is currently mapped to the provided value.booleanbooleanreplaceAsync(K key, V value) This method atomically replaces an entry only if the key is currently mapped to some value.replaceAsync(K key, V oldValue, V newValue) This method atomically replaces an entry only if the key is currently mapped to a given value.<T> TMethods inherited from class org.redisson.RedissonObject
addListener, addListener, addListenerAsync, addListenerAsync, addListenerId, addTrackingListener, addTrackingListenerAsync, checkNotBatch, copy, copy, copy, copyAndReplace, copyAndReplace, copyAndReplaceAsync, copyAndReplaceAsync, copyAsync, copyAsync, copyAsync, copyAsync, copyAsync, delete, deleteAsync, deleteAsync, dump, dumpAsync, encode, encode, encode, encode, encodeMapKey, encodeMapKey, encodeMapKeys, encodeMapValue, encodeMapValues, get, getCodec, getIdleTime, getIdleTimeAsync, getListenerIdsByName, getLockByMapKey, getLockByValue, getName, getNameByListenerId, getRawName, getRawName, getServiceManager, getSubscribeService, isExists, isExistsAsync, map, mapName, migrate, migrateAsync, move, moveAsync, prefixName, removeListener, removeListener, removeListenerAsync, removeListenerAsync, removeListenerAsync, removeListenerId, removeListeners, removeTrackingListener, removeTrackingListenerAsync, rename, renameAsync, renameAsync, renameAsync, renamenx, renamenxAsync, renamenxAsync, renamenxAsync, restore, restore, restoreAndReplace, restoreAndReplace, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, setName, sizeInMemory, sizeInMemoryAsync, sizeInMemoryAsync, sizeInMemoryAsync, suffixName, toSeconds, toStream, touch, touchAsync, unlink, unlinkAsyncMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.cache.Cache
getNameMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
JCache
public JCache(JCacheManager cacheManager, Redisson redisson, String name, JCacheConfiguration<K, V> config, boolean hasOwnRedisson)
-
-
Method Details
-
get
-
getAsync
Description copied from interface:CacheAsyncThis method retrieves an entry from the cache. If the cache uses the read-through pattern, and the method would return null because the entry is not present in the cache, then the cache'sCacheLoaderwill try to load the entry.- Specified by:
getAsyncin interfaceCacheAsync<K,V> - Parameters:
key- the key whose value should be returned- Returns:
- the element, or null if the entry does not exist.
-
getAll
-
getAllAsync
Description copied from interface:CacheAsyncThis method accepts a set of requested keys and retrieves a collection of entries from theCacheAsync, returning them as aMapof the associated values. If the cache uses the read-through pattern, and the method would return null for a key because an entry is not present in the cache, the Cache'sCacheLoaderwill try to load the entry. If a key's entry cannot be loaded, the key will not appear in the Map.- Specified by:
getAllAsyncin interfaceCacheAsync<K,V> - Parameters:
keys- The keys whose values should be returned.- Returns:
- A Map of entries associated with the given keys. If a key is not found in the cache, it will not be in the Map.
-
containsKey
-
containsKeyAsync
Description copied from interface:CacheAsyncThis method returns a Boolean true/false value, depending on whether theCacheAsynchas a mapping for a key k such that key.equals(k).- Specified by:
containsKeyAsyncin interfaceCacheAsync<K,V> - Parameters:
key- the key with a possible mapping in the cache.- Returns:
- true if such a mapping exists
-
loadAll
-
putAsync
Description copied from interface:CacheAsyncThis method places the given value V in the cache and associates it with the given key K. If theCacheAsyncalready has a mapping for the key, the previous value is replaced by the given value V. This occurs if and only ifc.containsKey(k)would return true.)- Specified by:
putAsyncin interfaceCacheAsync<K,V> - Parameters:
key- the key to place in the cachevalue- the value to associate with the given key- Returns:
- void
-
put
-
getAndPut
-
getAndPutAsync
Description copied from interface:CacheAsyncThis method places the given key and value in the cache. Any value already in the cache is returned and replaced by the new given value. This occurs if and only ifc.containsKey(k)would return true.) If there was no value already in the cache, the method returns null.- Specified by:
getAndPutAsyncin interfaceCacheAsync<K,V> - Parameters:
key- the key to place in the cachevalue- the value to associate with the given key- Returns:
- the previous value in the cache, or null if none already existed
-
putAll
-
putAllAsync
Description copied from interface:CacheAsyncThis method copies all of the entries from the given Map to theCacheAsync. This method is equivalent to callingCacheAsync.putAsync(Object, Object)on this cache one time for each mapping from key k to value v in the given Map. Individual puts may occur in any order. If entries in the cache corresponding to entries in the Map, or the Map itself, is changed or removed during this operation, then the behavior of this method is not defined. If default consistency mode is enabled, then each put is atomic but not the entire putAll operation. Listeners can observe individual updates.- Specified by:
putAllAsyncin interfaceCacheAsync<K,V> - Parameters:
map- the Map that contains the entries to be copied to the cache- Returns:
- void
-
putIfAbsent
-
putIfAbsentAsync
Description copied from interface:CacheAsyncThis method places the given key and value in the cache atomically, if the key is not already associated with a value in the cache.- Specified by:
putIfAbsentAsyncin interfaceCacheAsync<K,V> - Parameters:
key- the key to place in the cachevalue- the value to associate with the given key- Returns:
- true if the value was successfully placed in the cache
-
remove
-
removeAsync
Description copied from interface:CacheAsyncThis method deletes the mapping for a given key from the cache, if it is present. This occurs if and only if there is a mapping from key k to value v such that (key==null ? k==null : key.equals(k)). This method returns true if the removal was successful, or false if there was no such mapping.- Specified by:
removeAsyncin interfaceCacheAsync<K,V> - Parameters:
key- the key whose mapping will be deleted- Returns:
- returns true if successful, or false if there was no mapping
-
remove
-
removeAsync
Description copied from interface:CacheAsyncThis method atomically removes a key's mapping only if it is currently mapped to the provided value.- Specified by:
removeAsyncin interfaceCacheAsync<K,V> - Parameters:
key- the key whose mapping will be deletedvalue- the value that should be mapped to the given key- Returns:
- returns true if successful, or false if there was no such mapping
-
getAndRemove
-
getAndRemoveAsync
Description copied from interface:CacheAsyncThis method atomically removes the entry for a key only if it is currently mapped to some value.- Specified by:
getAndRemoveAsyncin interfaceCacheAsync<K,V> - Parameters:
key- the given key- Returns:
- the value if it existed, or null if it did not
-
replace
-
replaceAsync
Description copied from interface:CacheAsyncThis method atomically replaces an entry only if the key is currently mapped to a given value.- Specified by:
replaceAsyncin interfaceCacheAsync<K,V> - Parameters:
key- the key associated with the given oldValueoldValue- the value that should be associated with the keynewValue- the value that will be associated with the key- Returns:
- true if the value was replaced, or false if not
-
replace
-
replaceAsync
Description copied from interface:CacheAsyncThis method atomically replaces an entry only if the key is currently mapped to some value.- Specified by:
replaceAsyncin interfaceCacheAsync<K,V> - Parameters:
key- the key mapped to the given valuevalue- the value mapped to the given key- Returns:
- true if the value was replaced, or false if not
-
getAndReplace
-
getAndReplaceAsync
Description copied from interface:CacheAsyncThis method atomically replaces a given key's value if and only if the key is currently mapped to a value.- Specified by:
getAndReplaceAsyncin interfaceCacheAsync<K,V> - Parameters:
key- the key associated with the given valuevalue- the value associated with the given key- Returns:
- the previous value mapped to the given key, or null if there was no such mapping.
-
removeAll
-
removeAllAsync
Description copied from interface:CacheAsyncThis method deletes the entries for the given keys. The order in which the individual entries are removed is undefined. For every entry in the key set, the following are called: • any registeredCacheEntryRemovedListeners • if the cache is a write-through cache, theCacheWriterIf the key set is empty, theCacheWriteris not called.- Specified by:
removeAllAsyncin interfaceCacheAsync<K,V> - Parameters:
keys- the keys to remove- Returns:
- void
-
removeAll
public void removeAll() -
clear
public void clear() -
clearAsync
Description copied from interface:CacheAsyncThis method empties the cache's contents, without notifying listeners orCacheWriters.- Specified by:
clearAsyncin interfaceCacheAsync<K,V> - Returns:
- void
-
getConfiguration
-
invoke
-
invokeAll
-
getCacheManager
public javax.cache.CacheManager getCacheManager() -
close
public void close() -
isClosed
public boolean isClosed() -
unwrap
-
registerCacheEntryListener
-
deregisterCacheEntryListener
-
iterator
-