Groovy Documentation

[Groovy] Class SpringcacheService

java.lang.Object
  SpringcacheService

class SpringcacheService

Field Summary
private static java.lang.Object log

 
Property Summary
org.springframework.context.ApplicationContext applicationContext

boolean autoCreateCaches

net.sf.ehcache.CacheManager springcacheCacheManager

static java.lang.Object transactional

 
Constructor Summary
SpringcacheService()

 
Method Summary
void clearStatistics()

Clears statistics for all caches held by the service's cache manager.

private net.sf.ehcache.Ehcache createNewCacheWithDefaults(java.lang.String name)

java.lang.Object doWithBlockingCache(java.lang.String cacheName, java.io.Serializable key, groovy.lang.Closure closure)

A variant on doWithCache that guarantees the cache used will be a BlockingCache instance.

java.lang.Object doWithCache(java.lang.String cacheName, java.io.Serializable key, groovy.lang.Closure closure)

Calls a closure conditionally depending on whether a cache entry from a previous invocation exists.

private java.lang.Object doWithCacheInternal(net.sf.ehcache.Ehcache cache, java.io.Serializable key, groovy.lang.Closure closure)

void flush(java.lang.Object cacheNamePatterns)

Flushes the specified cache or set of caches.

void flushAll()

Flushes all caches held by the service's cache manager.

private java.lang.Object flushNamedCache(java.lang.String name)

net.sf.ehcache.constructs.blocking.BlockingCache getOrCreateBlockingCache(java.lang.String name)

Gets a named blocking cache instance from the cache manager.

net.sf.ehcache.Ehcache getOrCreateCache(java.lang.String name)

Gets a named cache instance from the cache manager.

static boolean isEnabled()

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Field Detail

log

private static final java.lang.Object log


 
Property Detail

applicationContext

org.springframework.context.ApplicationContext applicationContext


autoCreateCaches

boolean autoCreateCaches


springcacheCacheManager

net.sf.ehcache.CacheManager springcacheCacheManager


transactional

static java.lang.Object transactional


 
Constructor Detail

SpringcacheService

SpringcacheService()


 
Method Detail

clearStatistics

void clearStatistics()
Clears statistics for all caches held by the service's cache manager.


createNewCacheWithDefaults

private net.sf.ehcache.Ehcache createNewCacheWithDefaults(java.lang.String name)


doWithBlockingCache

java.lang.Object doWithBlockingCache(java.lang.String cacheName, java.io.Serializable key, groovy.lang.Closure closure)
A variant on doWithCache that guarantees the cache used will be a BlockingCache instance. The method handles clearing the lock if there is any exception raised.
Parameters:
cacheName - The name of the cache to use. If the named cache is not a BlockingCache instance it will be decorated with one and replaced in the cache manager.
key - The key used to get and put cache entries.
closure - The closure to invoke if no cache entry exists already.
Returns:
The cached value if a cache entry exists or the return value of the closure otherwise.


doWithCache

java.lang.Object doWithCache(java.lang.String cacheName, java.io.Serializable key, groovy.lang.Closure closure)
Calls a closure conditionally depending on whether a cache entry from a previous invocation exists. If the closure is called its return value is written to the cache..
Parameters:
cacheName - The name of the cache to use.
key - The key used to get and put cache entries.
closure - The closure to invoke if no cache entry exists already.
Returns:
The cached value if a cache entry exists or the return value of the closure otherwise.


doWithCacheInternal

private java.lang.Object doWithCacheInternal(net.sf.ehcache.Ehcache cache, java.io.Serializable key, groovy.lang.Closure closure)


flush

void flush(java.lang.Object cacheNamePatterns)
Flushes the specified cache or set of caches.
Parameters:
cacheNamePatterns - can be a single cache name or a regex pattern or a Collection/array of them.


flushAll

void flushAll()
Flushes all caches held by the service's cache manager.


flushNamedCache

private java.lang.Object flushNamedCache(java.lang.String name)


getOrCreateBlockingCache

net.sf.ehcache.constructs.blocking.BlockingCache getOrCreateBlockingCache(java.lang.String name)
Gets a named blocking cache instance from the cache manager. If the named cache is non-blocking it will be decorated and replaced. If no such cache exists it will be created.
Parameters:
name - The cache name.
Returns:
a BlockingCache instance.


getOrCreateCache

net.sf.ehcache.Ehcache getOrCreateCache(java.lang.String name)
Gets a named cache instance from the cache manager. If no such cache exists it will be created.
Parameters:
name - The cache name.
Returns:
a cache instance.


isEnabled

static boolean isEnabled()


 

Groovy Documentation