public interface Cache
@Inject Cache cache
.
Heavily inspired by excellent Play! 1.2.5 implementation.Modifier and Type | Method and Description |
---|---|
void |
add(String key,
Object value,
int expirationInSeconds)
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 expirationInSeconds)
Replaces key with new value.
|
boolean |
safeAdd(String key,
Object value,
int expirationInSeconds)
Similar to
delete method. |
boolean |
safeDelete(String key)
Similar to
delete method. |
boolean |
safeReplace(String key,
Object value,
int expirationInSeconds)
Similar to
delete method. |
boolean |
safeSet(String key,
Object value,
int expirationInSeconds)
Similar to
delete method. |
void |
set(String key,
Object value,
int expirationInSeconds)
Adds object of cache.
|
void add(String key, Object value, int expirationInSeconds)
key
- The key of the object to use for caching.value
- The value of the object to add to the cache.expirationInSeconds
- Expiration time in seconds.boolean safeAdd(String key, Object value, int expirationInSeconds)
delete
method.
BUT it blocks until execution succeeds / fails AND wraps
exceptions in a simple true / false return valuekey
- The key of the object to use for caching.value
- The value of the object to add in the cache.expirationInSeconds
- Expiration time in seconds.void set(String key, Object value, int expirationInSeconds)
key
- The key of the object to use for caching.value
- The value of the object to set in the cache.expirationInSeconds
- Expiration time in seconds.boolean safeSet(String key, Object value, int expirationInSeconds)
delete
method.
BUT it blocks until execution succeeds / fails AND wraps
exceptions in a simple true / false return valuekey
- The key of the object to use for caching.value
- The value of the object to set in the cache.expirationInSeconds
- Expiration time in seconds.void replace(String key, Object value, int expirationInSeconds)
key
- The key of the object to use for caching.value
- The value of the object to replace in the cache.expirationInSeconds
- Expiration time in seconds.boolean safeReplace(String key, Object value, int expirationInSeconds)
delete
method.
BUT it blocks until execution succeeds / fails AND wraps
exceptions in a simple true / false return valuekey
- The key of the object to use for caching.value
- The value of the object to replace in the cache.expirationInSeconds
- Expiration time in seconds.Object get(String key)
key
- The key of the object to retrieve.Map<String,Object> get(String[] keys)
keys
- The list of keys to retrieve from Cache.long incr(String key, int by)
key
- The key to incrementby
- Value by which to increment.long decr(String key, int by)
key
- The key to decrementby
- Value by which to decrement.void clear()
void delete(String key)
key
- The key to delete.boolean safeDelete(String key)
delete
method.
BUT it blocks until execution succeeds / fails AND wraps
exceptions in a simple true / false return valuekey
- The key to deleteCopyright © 2019 ninjaframework. All rights reserved.