public interface CachingSupport
Modifier and Type | Method and Description |
---|---|
Cache |
getDistributedCache()
Applicable only when the clustering is enabled and deployed as a cluster.
|
Cache |
getDistributedPermanentCache()
Applicable only when the clustering is enabled and deployed as a cluster.
|
Cache |
getDistributedPersistentCache()
Applicable only when the clustering is enabled and deployed as a cluster.
|
Cache |
getLocalCache()
Gets the
Cache instance which is available locally in the node, and expires it's
entries in a given time. |
Cache |
getLocalPermanentCache()
Gets the
Cache instance which is available locally in the node, and keeps its
contents in the cache within a session. |
Cache |
getLocalPersistentCache()
Gets the
Cache instance which is available locally in the node, and keeps its
contents in the cache forever across the sessions. |
Cache getLocalCache()
Cache
instance which is available locally in the node, and expires it's
entries in a given time. It also has a time to live and nothing is guaranteed to be present
in this cache. If you need your content to be present through out the session, use the
getLocalPermanentCache()
to get the cache which will give you the permanent cache.
This cache overflows the content to disk in case of exceeding the in-memory cache size, which defaults to 10000 entries. How ever after storing another 1000 entries in the disk, the cache will permanently overflow, which sniffs something wrong in your mediation, as the content in this cache is automatically cleared in the expiration time.
Cache getLocalPermanentCache()
Cache
instance which is available locally in the node, and keeps its
contents in the cache within a session. The contents in this cache will never be expired but
they are not persisted, so they will be lost at a System/JVM restart. If you want content to
be available across JVM sessions, use getLocalPersistentCache()
instead.
You should be using this with care, as the content life cycle is not managed by the cache it is your responsibility to manage the cache content life cycle. Otherwise you might get into a resource exhaustion. This cache overflows the content to disk in case of exceeding the in-memory cache size, which defaults to 1000 entries, while there is no limit to the content which will be overflowed to disk
Cache getLocalPersistentCache()
Cache
instance which is available locally in the node, and keeps its
contents in the cache forever across the sessions. In other words the content will be
persisted to the disk.
Once again you should be extra careful about the usage, as the content will be there even after a system/JVM restart. It is possible to crash the disk space and the data persisted in the disk be lost and the cache is not handling that case as it really cannot do anything for the data corruption. This cache by default keeps only 100 entries in-memory and it off-loads the content to disk and loads the content from disk depending on the demand for those entries.
You could treat this as a NO-SQL persistent store, available locally in your node. If you
want the content to be available among the cluster in the case of a clustered deployment, use
the getDistributedPersistentCache()
Cache getDistributedCache()
getLocalCache()
but
this replicates the content across the nodes in the cluster.
Not like the local equivalent to which you can put any thing, this only accepts
Serializable
content as both key and value of the entries in the cache. This
is because the content you put has to be serialized as the cache needs to replicate the
content using RMI.
If the node is starting up later in the cluster, (i.e. it joins a cluster with a state) the node bootstraps the cache content from one of its arbitrarily selected peers.
Cache getDistributedPermanentCache()
getLocalPermanentCache()
but this replicates the content across the nodes in the
cluster.
Not like the local equivalent to which you can put any thing, this only accepts
Serializable
content as both key and value of the entries in the cache. This
is because the content you put has to be serialized as the cache needs to replicate the
content using RMI.
You should take extra care about the content life cycle, as the cache doesn't expire the entries that you put. If the node is starting up later in the cluster, (i.e. it joins a cluster with a state) the node bootstraps the cache content from one of its arbitrarily selected peers. Because of the above bootstrap, not like in the local equivalent unless the complete cluster goes off the content will be preserved even on a System/JVM restart on a single node, as it will bootstrap it's cache content from a peer in the cluster.
Cache getDistributedPersistentCache()
getLocalPersistentCache()
but this replicates the content across the nodes in the
cluster.
Not like the local equivalent to which you can put any thing, this only accepts
Serializable
content as both key and value of the entries in the cache. This
is because the content you put has to be serialized as the cache needs to replicate the
content using RMI.
You should take extra care about the content life cycle, as the cache doesn't expire the entries that you put. If the node is starting up later in the cluster, (i.e. it joins a cluster with a state) the node bootstraps the cache content from one of its arbitrarily selected peers.
Copyright © 2010–2016 AdroitLogic. All rights reserved.