Magnolia 5.4 reached end of life on November 15, 2018. This branch is no longer supported, see End-of-life policy.
...
Warning |
---|
Whether cache is persistent depends on the underlying implementation. For non-persistent implementations the cache must be rebuilt after server restart. See Cache implementations for more. |
Implementations:
Not persistent | EhCache with free license |
Persistent |
Achieve an instance of
Javadoc | ||
---|---|---|
|
...
Advanced Tables - Table Plus | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||
|
The /modules/cache/config/cacheFactory/caches/fooBarCache
node defines the cache name. fooBarCache
is the "name" of the cache which was also used above when acquiring the Cache object within Java code.
...
Code Block | ||
---|---|---|
| ||
void put(Object key, Object value); void put(Object key, Object value, int timeToLiveInSeconds); |
Arguments:
key | required The identifier of the object to cache |
value | required The object to cache |
timeToLiveInSeconds | optional The lifetime of the cached object in seconds. Tip: The lifetime also can be configured globally, and you can configure a flush policy to clear the cache when some condition is met, or you may want to delete cached objects programmatically (see #remove and #clear below). |
Example:
Code Block | ||
---|---|---|
| ||
public class MyClass { public Object put(Object key, Object value){ Cache cache = cacheFactoryProvider.get().get().getCache("fooBarCache"); cache.put(key, value); return value; } public Object put(Object key, Object value, int timeToLiveInSeconds){ Cache cache = cacheFactoryProvider.get().get().getCache("fooBarCache"); cache.put(key, value, timeToLiveInSeconds); return value; } } |
...
Info |
---|
Use It is good practice to call If there is no object for a key, add |
...