public class CacheEhCacheImpl extends Object implements Cache
Ehcache is an open source, standards-based cache used to boost performance, offload the database and simplify scalability. Ehcache is robust, proven and full-featured and this has made it the most widely-used Java-based cache.
expiration is specified in seconds
Heavily inspired by excellent Play! 1.2.5 implementation.| Constructor and Description |
|---|
CacheEhCacheImpl(org.slf4j.Logger logger) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(String key,
Object value,
int expiration)
Add object to cache.
|
void |
clear()
Clear all values in cache.
|
long |
decr(String key,
int by)
Decrements key by value.
|
void |
delete(String key)
Delete key from cache.
|
Object |
get(String key)
Returns the object for this key or null if not found.
|
Map<String,Object> |
get(String[] keys)
Returns all objects for the keys.
|
long |
incr(String key,
int by)
Increments key by value.
|
void |
replace(String key,
Object value,
int expiration)
Replaces key with new value.
|
boolean |
safeAdd(String key,
Object value,
int expiration)
Similar to
delete method. |
boolean |
safeDelete(String key)
Similar to
delete method. |
boolean |
safeReplace(String key,
Object value,
int expiration)
Similar to
delete method. |
boolean |
safeSet(String key,
Object value,
int expiration)
Similar to
delete method. |
void |
set(String key,
Object value,
int expiration)
Adds object of cache.
|
void |
stop() |
public void add(String key, Object value, int expiration)
Cachepublic void clear()
Cachepublic long decr(String key, int by)
Cachepublic void delete(String key)
Cachepublic Object get(String key)
Cachepublic Map<String,Object> get(String[] keys)
Cachepublic long incr(String key, int by)
Cachepublic void replace(String key, Object value, int expiration)
Cachepublic boolean safeAdd(String key, Object value, int expiration)
Cachedelete method.
BUT it blocks until execution succeeds / fails AND wraps
exceptions in a simple true / false return valuepublic boolean safeDelete(String key)
Cachedelete method.
BUT it blocks until execution succeeds / fails AND wraps
exceptions in a simple true / false return valuesafeDelete in interface Cachekey - The key to deletepublic boolean safeReplace(String key, Object value, int expiration)
Cachedelete method.
BUT it blocks until execution succeeds / fails AND wraps
exceptions in a simple true / false return valuesafeReplace in interface Cachekey - The key of the object to use for caching.value - The value of the object to replace in the cache.expiration - Expiration time in seconds.public boolean safeSet(String key, Object value, int expiration)
Cachedelete method.
BUT it blocks until execution succeeds / fails AND wraps
exceptions in a simple true / false return valuepublic void set(String key, Object value, int expiration)
Cachepublic void stop()
Copyright © 2019 ninjaframework. All rights reserved.