Skip to content
This repository has been archived by the owner on Oct 3, 2022. It is now read-only.

Fix for Issue #54 #55

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ehcache-jcache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public JCacheManager(final JCacheCachingProvider jCacheCachingProvider, final Ca
this.cacheManager = cacheManager;
this.uri = uri;
this.props = props;
refreshAllCaches();
//refreshAllCaches();
}

@Override
Expand Down Expand Up @@ -143,7 +143,7 @@ public <K, V> Cache<K, V> getCache(final String cacheName, final Class<K> keyTyp
if (cache == null) {
return null;
}
jCache = new JCache<K, V>(this, new JCacheConfiguration<K, V>(null, null, keyType, valueType), cache);
jCache = new JCache<K, V>(this, new JCacheConfiguration<K, V>(cache.getCacheConfiguration(), null, keyType, valueType), cache);
final JCache<K, V> previous = allCaches.putIfAbsent(cacheName, jCache);
if(previous != null) {
jCache = previous;
Expand All @@ -161,7 +161,11 @@ public <K, V> Cache<K, V> getCache(final String cacheName, final Class<K> keyTyp
public <K, V> Cache<K, V> getCache(final String cacheName) {
final JCache<K, V> 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 ||
Expand Down