From f39052a7a89a6bf18a195b9815cf899ccd1debeb Mon Sep 17 00:00:00 2001 From: apptaro Date: Tue, 5 Dec 2017 13:14:22 +0900 Subject: [PATCH 1/4] Fix for Issue #54 --- .../src/main/java/org/ehcache/jcache/JCacheManager.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ehcache-jcache/src/main/java/org/ehcache/jcache/JCacheManager.java b/ehcache-jcache/src/main/java/org/ehcache/jcache/JCacheManager.java index 5792955..3e0d007 100644 --- a/ehcache-jcache/src/main/java/org/ehcache/jcache/JCacheManager.java +++ b/ehcache-jcache/src/main/java/org/ehcache/jcache/JCacheManager.java @@ -71,7 +71,7 @@ public JCacheManager(final JCacheCachingProvider jCacheCachingProvider, final Ca this.cacheManager = cacheManager; this.uri = uri; this.props = props; - refreshAllCaches(); + //refreshAllCaches(); } @Override @@ -161,7 +161,11 @@ public Cache getCache(final String cacheName, final Class keyTyp public Cache getCache(final String cacheName) { final JCache jCache = allCaches.get(cacheName); if(jCache == null) { - refreshAllCaches(); + //refreshAllCaches(); + final net.sf.ehcache.Cache cache = cacheManager.getCache(cacheName); + if (cache != null) { + allCaches.put(cacheName, new JCache(this, new JCacheConfiguration(cache.getCacheConfiguration()), cache)); + } return allCaches.get(cacheName); } if(jCache.getConfiguration(CompleteConfiguration.class).getKeyType() != Object.class || From 11f93140094794304f70d9847ed28b24468bfaa3 Mon Sep 17 00:00:00 2001 From: apptaro Date: Tue, 5 Dec 2017 13:19:12 +0900 Subject: [PATCH 2/4] Workaround build error with Java 8 --- ehcache-jcache/pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ehcache-jcache/pom.xml b/ehcache-jcache/pom.xml index cfcce58..985f1cb 100755 --- a/ehcache-jcache/pom.xml +++ b/ehcache-jcache/pom.xml @@ -83,6 +83,9 @@ org.apache.maven.plugins maven-javadoc-plugin 2.8 + + -Xdoclint:none + attach-javadocs From dbe884064460f955ca8d4fea5556a2e6bd4803e3 Mon Sep 17 00:00:00 2001 From: apptaro Date: Fri, 25 Nov 2022 21:58:12 +0900 Subject: [PATCH 3/4] Additional Fix for Issue #54 --- .../src/main/java/org/ehcache/jcache/JCacheManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ehcache-jcache/src/main/java/org/ehcache/jcache/JCacheManager.java b/ehcache-jcache/src/main/java/org/ehcache/jcache/JCacheManager.java index 3e0d007..54be461 100644 --- a/ehcache-jcache/src/main/java/org/ehcache/jcache/JCacheManager.java +++ b/ehcache-jcache/src/main/java/org/ehcache/jcache/JCacheManager.java @@ -143,7 +143,7 @@ public Cache getCache(final String cacheName, final Class keyTyp if (cache == null) { return null; } - jCache = new JCache(this, new JCacheConfiguration(null, null, keyType, valueType), cache); + jCache = new JCache(this, new JCacheConfiguration(cache.getCacheConfiguration(), null, keyType, valueType), cache); final JCache previous = allCaches.putIfAbsent(cacheName, jCache); if(previous != null) { jCache = previous; From 57d1251e45d1a2401bab24bf80661b3fad2cb167 Mon Sep 17 00:00:00 2001 From: apptaro Date: Mon, 28 Nov 2022 14:46:58 +0900 Subject: [PATCH 4/4] Fixed getExpiryForCreation/getExpiryForAccess/getExpiryForUpdate --- .../ehcache/jcache/JCacheConfiguration.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/ehcache-jcache/src/main/java/org/ehcache/jcache/JCacheConfiguration.java b/ehcache-jcache/src/main/java/org/ehcache/jcache/JCacheConfiguration.java index 61928ae..535f151 100644 --- a/ehcache-jcache/src/main/java/org/ehcache/jcache/JCacheConfiguration.java +++ b/ehcache-jcache/src/main/java/org/ehcache/jcache/JCacheConfiguration.java @@ -98,17 +98,35 @@ public JCacheConfiguration(final CacheConfiguration cacheConfiguration, final Co expiryPolicy = new ExpiryPolicy() { @Override public Duration getExpiryForCreation() { - return new Duration(TimeUnit.SECONDS, cacheConfiguration.getTimeToLiveSeconds()); + if (cacheConfiguration.getTimeToLiveSeconds() > 0) { + return new Duration(TimeUnit.SECONDS, cacheConfiguration.getTimeToLiveSeconds()); + } else if (cacheConfiguration.getTimeToIdleSeconds() > 0) { + return new Duration(TimeUnit.SECONDS, cacheConfiguration.getTimeToIdleSeconds()); + } else { + return Duration.ETERNAL; + } } @Override public Duration getExpiryForAccess() { - return new Duration(TimeUnit.SECONDS, cacheConfiguration.getTimeToLiveSeconds()); + if (cacheConfiguration.getTimeToLiveSeconds() > 0) { + return null; + } else if (cacheConfiguration.getTimeToIdleSeconds() > 0) { + return new Duration(TimeUnit.SECONDS, cacheConfiguration.getTimeToIdleSeconds()); + } else { + return null; + } } @Override public Duration getExpiryForUpdate() { - return getExpiryForCreation(); + if (cacheConfiguration.getTimeToLiveSeconds() > 0) { + return new Duration(TimeUnit.SECONDS, cacheConfiguration.getTimeToLiveSeconds()); + } else if (cacheConfiguration.getTimeToIdleSeconds() > 0) { + return new Duration(TimeUnit.SECONDS, cacheConfiguration.getTimeToIdleSeconds()); + } else { + return null; + } } }; }