public final class CacheMethods extends Object
Constructor and Description |
---|
CacheMethods() |
Modifier and Type | Method and Description |
---|---|
static <K,V> Map<K,V> |
cacheGet(String cacheName,
Collection<?> keys)
Get entries in the cache for the each of the given keys as a map, or an empty map if no values were cached
for those keys.
|
static <T> T |
cacheGet(String cacheName,
Object key)
Get the value of a cache entry using the entry's associated key.
|
static <T> T |
cacheGet(String cacheName,
Object key,
groovy.lang.Closure loader)
Get the value in the cache for the given key, or the value returned by the closure if no value was cached
for that key.
|
static <T> T |
cacheGet(String cacheName,
Object key,
T defaultValue)
Get the value in the cache for the given key, or a provided default value if no value was cached
for that key.
|
static void |
cacheInvalidate(String cacheName,
Object key)
Invalidate the given key in the cache.
|
static void |
cacheInvalidateAll(String cacheName,
Collection<?> keys)
Invalidate the given keys in the cache.
|
static void |
cachePut(String cacheName,
Object key,
Object value)
Put the value in the cache, and assign it to the given key.
|
static void |
cachePutAll(String cacheName,
Map<?,?> entries)
Put the given entries in the cache.
|
@GloopParameter(name="value") public static <T> T cacheGet(@GloopParameter(allowNull=false) String cacheName, @GloopParameter(allowNull=false) Object key)
cacheName
- the name of the cache in the current packagekey
- the cache entry's associated keynull
if no value was cached for the provided keyio.toro.martini.cache.CacheManagerException
- if cache couldn't be constructed from cacheName
@GloopParameter(name="values") public static <K,V> Map<K,V> cacheGet(@GloopParameter(allowNull=false) String cacheName, @GloopParameter(allowNull=false) Collection<?> keys)
cacheName
- the name of the cache in the current packagekeys
- The keys for the entries that need to be fetched@GloopParameter(name="value") public static <T> T cacheGet(@GloopParameter(allowNull=false) String cacheName, @GloopParameter(allowNull=false) Object key, @GloopParameter(allowNull=false) groovy.lang.Closure loader)
cacheName
- the name of the cache in the current packagekey
- the cache entry's associated keyloader
- the closure that loads the value for key
if it doesn't exist@GloopParameter(name="value") public static <T> T cacheGet(@GloopParameter(allowNull=false) String cacheName, @GloopParameter(allowNull=false) Object key, T defaultValue)
cacheName
- the name of the cache in the current packagekey
- the cache entry's associated keydefaultValue
- the value for key
if it doesn't existdefaultValue
if an entry for key
does not existpublic static void cachePut(@GloopParameter(allowNull=false) String cacheName, @GloopParameter(allowNull=false) Object key, @GloopParameter(allowNull=false) Object value)
cacheName
- the name of the cache in the current packagekey
- the cache keyvalue
- the cache valuepublic static void cachePutAll(@GloopParameter(allowNull=false) String cacheName, @GloopParameter(allowNull=false) Map<?,?> entries)
cacheName
- the name of the cache in the current packageentries
- the entries to put in cachepublic static void cacheInvalidate(@GloopParameter(allowNull=false) String cacheName, @GloopParameter(allowNull=false) Object key)
cacheName
- the name of the cache in the current packagekey
- the key to invalidatepublic static void cacheInvalidateAll(@GloopParameter(allowNull=false) String cacheName, @GloopParameter(allowNull=false) Collection<?> keys)
cacheName
- the name of the cache in the current packagekeys
- the keys to invalidateCopyright © 2020. All rights reserved.