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 @@ ...@@ -44,6 +44,11 @@
Hazelcast Clustering Plugin Changelog Hazelcast Clustering Plugin Changelog
</h1> </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> <p><b>2.2.3</b> -- September 15, 2017</p>
<ul> <ul>
<li>Use an event rather than an arbitrary delay before starting clustering</li> <li>Use an event rather than an arbitrary delay before starting clustering</li>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<name>Hazelcast plugin</name> <name>Hazelcast plugin</name>
<description>Adds clustering support</description> <description>Adds clustering support</description>
<author>Tom Evans</author> <author>Tom Evans</author>
<version>2.2.3</version> <version>2.2.4</version>
<date>09/15/2017</date> <date>10/26/2017</date>
<minServerVersion>4.2.0</minServerVersion> <minServerVersion>4.2.0</minServerVersion>
</plugin> </plugin>
...@@ -44,6 +44,7 @@ public class ClusteredCache implements Cache { ...@@ -44,6 +44,7 @@ public class ClusteredCache implements Cache {
* The map is used for distributed operations such as get, put, etc. * The map is used for distributed operations such as get, put, etc.
*/ */
protected IMap map; protected IMap map;
private final int hazelcastLifetimeInSeconds;
private String name; private String name;
private long numberOfGets = 0; private long numberOfGets = 0;
...@@ -52,9 +53,11 @@ public class ClusteredCache implements Cache { ...@@ -52,9 +53,11 @@ public class ClusteredCache implements Cache {
* *
* @param name a name for the cache, which should be unique per vm. * @param name a name for the cache, which should be unique per vm.
* @param cache the cache implementation * @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; map = cache;
this.hazelcastLifetimeInSeconds = hazelcastLifetimeInSeconds;
setName(name); setName(name);
} }
...@@ -81,7 +84,7 @@ public class ClusteredCache implements Cache { ...@@ -81,7 +84,7 @@ public class ClusteredCache implements Cache {
public Object put(Object key, Object object) { public Object put(Object key, Object object) {
if (object == null) { return null; } if (object == null) { return null; }
return map.put(key, object); return map.put(key, object, hazelcastLifetimeInSeconds, TimeUnit.SECONDS);
} }
public Object get(Object key) { public Object get(Object key) {
......
...@@ -222,7 +222,7 @@ public class ClusteredCacheFactory implements CacheFactoryStrategy { ...@@ -222,7 +222,7 @@ public class ClusteredCacheFactory implements CacheFactoryStrategy {
final MapConfig mapConfig = hazelcast.getConfig().getMapConfig(name); final MapConfig mapConfig = hazelcast.getConfig().getMapConfig(name);
mapConfig.setTimeToLiveSeconds(hazelcastLifetimeInSeconds); mapConfig.setTimeToLiveSeconds(hazelcastLifetimeInSeconds);
mapConfig.setMaxSizeConfig(new MaxSizeConfig(hazelcastMaxCacheSize, MaxSizeConfig.MaxSizePolicy.USED_HEAP_SIZE)); 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) { 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