Unverified Commit 8b664a7a authored by Dave Cridland's avatar Dave Cridland Committed by GitHub

Merge pull request #904 from GregDThomas/OF-1416

OF-1416: Ensure that hazelcast cache entries expire correctly
parents a26a0b3f 7c7dbb02
......@@ -44,6 +44,11 @@
Hazelcast Clustering Plugin Changelog
</h1>
<p><b>2.2.4</b> -- October 26, 2017</p>
<ul>
<li>[<a href='http://www.igniterealtime.org/issues/browse/OF-1416'>OF-1416</a>] - Dynamically created ClusteredCache entries not expiring</li>
</ul>
<p><b>2.2.3</b> -- September 15, 2017</p>
<ul>
<li>Use an event rather than an arbitrary delay before starting clustering</li>
......
......@@ -5,7 +5,7 @@
<name>Hazelcast plugin</name>
<description>Adds clustering support</description>
<author>Tom Evans</author>
<version>2.2.3</version>
<date>09/15/2017</date>
<version>2.2.4</version>
<date>10/26/2017</date>
<minServerVersion>4.2.0</minServerVersion>
</plugin>
......@@ -44,6 +44,7 @@ public class ClusteredCache implements Cache {
* The map is used for distributed operations such as get, put, etc.
*/
protected IMap map;
private final int hazelcastLifetimeInSeconds;
private String name;
private long numberOfGets = 0;
......@@ -52,9 +53,11 @@ public class ClusteredCache implements Cache {
*
* @param name a name for the cache, which should be unique per vm.
* @param cache the cache implementation
* @param hazelcastLifetimeInSeconds the lifetime of cache entries
*/
protected ClusteredCache(String name, IMap cache) {
protected ClusteredCache(String name, IMap cache, final int hazelcastLifetimeInSeconds) {
map = cache;
this.hazelcastLifetimeInSeconds = hazelcastLifetimeInSeconds;
setName(name);
}
......@@ -81,7 +84,7 @@ public class ClusteredCache implements Cache {
public Object put(Object key, Object object) {
if (object == null) { return null; }
return map.put(key, object);
return map.put(key, object, hazelcastLifetimeInSeconds, TimeUnit.SECONDS);
}
public Object get(Object key) {
......
......@@ -222,7 +222,7 @@ public class ClusteredCacheFactory implements CacheFactoryStrategy {
final MapConfig mapConfig = hazelcast.getConfig().getMapConfig(name);
mapConfig.setTimeToLiveSeconds(hazelcastLifetimeInSeconds);
mapConfig.setMaxSizeConfig(new MaxSizeConfig(hazelcastMaxCacheSize, MaxSizeConfig.MaxSizePolicy.USED_HEAP_SIZE));
return new ClusteredCache(name, hazelcast.getMap(name));
return new ClusteredCache(name, hazelcast.getMap(name), hazelcastLifetimeInSeconds);
}
public void destroyCache(Cache cache) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment