Author: shawkins
Date: 2011-08-26 21:41:12 -0400 (Fri, 26 Aug 2011)
New Revision: 3428
Modified:
branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java
branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java
branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java
Log:
TEIID-1728 fix for expirations not being handled
Modified:
branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java
===================================================================
---
branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java 2011-08-26
16:59:18 UTC (rev 3427)
+++
branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java 2011-08-27
01:41:12 UTC (rev 3428)
@@ -35,6 +35,12 @@
public ExpirationAwareCache(Cache cacheStore, Fqn fqn) {
super(cacheStore, fqn);
}
+
+ @Override
+ protected boolean validateNode(Node node) {
+ Long future = (Long) node.get(ExpirationAlgorithmConfig.EXPIRATION_KEY);
+ return future == null || future > System.currentTimeMillis();
+ }
@Override
public V put(K key, V value) {
Modified:
branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java
===================================================================
---
branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java 2011-08-26
16:59:18 UTC (rev 3427)
+++
branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java 2011-08-27
01:41:12 UTC (rev 3428)
@@ -51,11 +51,15 @@
public V get(K key) {
Node<K, V> node = getRootNode();
Node child = node.getChild(getFqn(key));
- if (child != null) {
+ if (child != null && validateNode(child)) {
return (V)child.get(key);
}
return null;
}
+
+ protected boolean validateNode(Node node) {
+ return true;
+ }
protected Fqn<String> getFqn(K key) {
if (key.getClass().isPrimitive() || key instanceof String) {
Modified:
branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java
===================================================================
---
branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java 2011-08-26
16:59:18 UTC (rev 3427)
+++
branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java 2011-08-27
01:41:12 UTC (rev 3428)
@@ -29,6 +29,7 @@
import org.jboss.cache.Node;
import org.jboss.cache.Region;
import org.jboss.cache.config.EvictionAlgorithmConfig;
+import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
import org.jboss.cache.eviction.LRUAlgorithmConfig;
@@ -71,6 +72,8 @@
Region cacheRegion = this.cacheStore.getRegion(node.getFqn(), true);
cacheRegion.setEvictionRegionConfig(buildEvictionConfig(node.getFqn(), config));
cacheRegion.activate();
+ cacheRegion = this.cacheStore.getRegion(node.getFqn(), true);
+ cacheRegion.setEvictionRegionConfig(buildEvictionConfig(node.getFqn(), config));
JBossCache jc = null;
if (config != null && config.getPolicy().equals(Policy.EXPIRATION)) {
Show replies by date