diff --git a/src/main/java/org/redisson/spring/cache/CacheConfig.java b/src/main/java/org/redisson/spring/cache/CacheConfig.java
index 9cc10fa26..f89208e17 100644
--- a/src/main/java/org/redisson/spring/cache/CacheConfig.java
+++ b/src/main/java/org/redisson/spring/cache/CacheConfig.java
@@ -21,7 +21,6 @@ import java.io.InputStream;
import java.io.Reader;
import java.net.URL;
import java.util.Map;
-import java.util.concurrent.TimeUnit;
/**
* Cache config object used for Spring cache configuration.
@@ -33,12 +32,8 @@ public class CacheConfig {
private long ttl;
- private TimeUnit ttlUnit;
-
private long maxIdleTime;
- private TimeUnit maxIdleUnit;
-
/**
* Creates config object with
* ttl = 0
and maxIdleTime = 0
.
@@ -50,22 +45,20 @@ public class CacheConfig {
/**
* Creates config object.
*
- * @param ttl - time to live for key\value entry.
+ * @param ttl - time to live for key\value entry in milliseconds.
* If 0
then time to live doesn't affect entry expiration.
* @param ttlUnit
- * @param maxIdleTime - max idle time for key\value entry.
+ * @param maxIdleTime - max idle time for key\value entry in milliseconds.
* If 0
then max idle time doesn't affect entry expiration.
* @param maxIdleUnit
*
maxIdleTime
and ttl
params are equal to 0
* then entry stores infinitely.
*/
- public CacheConfig(long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit) {
+ public CacheConfig(long ttl, long maxIdleTime) {
super();
this.ttl = ttl;
- this.ttlUnit = ttlUnit;
this.maxIdleTime = maxIdleTime;
- this.maxIdleUnit = maxIdleUnit;
}
public long getTTL() {
@@ -73,44 +66,29 @@ public class CacheConfig {
}
/**
- * Set time to live for key\value entry.
+ * Set time to live for key\value entry in milliseconds.
*
- * @param ttl - time to live for key\value entry.
+ * @param ttl - time to live for key\value entry in milliseconds.
* If 0
then time to live doesn't affect entry expiration.
*/
public void setTTL(long ttl) {
this.ttl = ttl;
}
- public TimeUnit getTTLUnit() {
- return ttlUnit;
- }
-
- public void setTTLUnit(TimeUnit ttlUnit) {
- this.ttlUnit = ttlUnit;
- }
-
public long getMaxIdleTime() {
return maxIdleTime;
}
/**
- * Set max idle time for key\value entry.
+ * Set max idle time for key\value entry in milliseconds.
*
- * @param maxIdleTime - max idle time for key\value entry.
+ * @param maxIdleTime - max idle time for key\value entry in milliseconds.
* If 0
then max idle time doesn't affect entry expiration.
*/
public void setMaxIdleTime(long maxIdleTime) {
this.maxIdleTime = maxIdleTime;
}
- public TimeUnit getMaxIdleUnit() {
- return maxIdleUnit;
- }
- public void setMaxIdleUnit(TimeUnit maxIdleUnit) {
- this.maxIdleUnit = maxIdleUnit;
- }
-
/**
* Read config objects stored in JSON format from String
*
diff --git a/src/main/java/org/redisson/spring/cache/RedissonCache.java b/src/main/java/org/redisson/spring/cache/RedissonCache.java
index f0c5e584a..740ff8a69 100644
--- a/src/main/java/org/redisson/spring/cache/RedissonCache.java
+++ b/src/main/java/org/redisson/spring/cache/RedissonCache.java
@@ -15,6 +15,8 @@
*/
package org.redisson.spring.cache;
+import java.util.concurrent.TimeUnit;
+
import org.redisson.core.RMap;
import org.redisson.core.RMapCache;
import org.springframework.cache.Cache;
@@ -75,7 +77,7 @@ public class RedissonCache implements Cache {
@Override
public void put(Object key, Object value) {
if (mapCache != null) {
- mapCache.fastPut(key, value, config.getTTL(), config.getTTLUnit(), config.getMaxIdleTime(), config.getMaxIdleUnit());
+ mapCache.fastPut(key, value, config.getTTL(), TimeUnit.MILLISECONDS, config.getMaxIdleTime(), TimeUnit.MILLISECONDS);
} else {
map.fastPut(key, value);
}
@@ -84,7 +86,7 @@ public class RedissonCache implements Cache {
public ValueWrapper putIfAbsent(Object key, Object value) {
Object prevValue;
if (mapCache != null) {
- prevValue = mapCache.putIfAbsent(key, value, config.getTTL(), config.getTTLUnit(), config.getMaxIdleTime(), config.getMaxIdleUnit());
+ prevValue = mapCache.putIfAbsent(key, value, config.getTTL(), TimeUnit.MILLISECONDS, config.getMaxIdleTime(), TimeUnit.MILLISECONDS);
} else {
prevValue = map.putIfAbsent(key, value);
}
diff --git a/src/test/java/org/redisson/spring/cache/RedissonSpringCacheTest.java b/src/test/java/org/redisson/spring/cache/RedissonSpringCacheTest.java
index 0e3e413eb..4c8411362 100644
--- a/src/test/java/org/redisson/spring/cache/RedissonSpringCacheTest.java
+++ b/src/test/java/org/redisson/spring/cache/RedissonSpringCacheTest.java
@@ -2,6 +2,7 @@ package org.redisson.spring.cache;
import static org.assertj.core.api.Assertions.assertThat;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@@ -88,9 +89,9 @@ public class RedissonSpringCacheTest {
}
@Bean
- CacheManager cacheManager(RedissonClient redissonClient) {
+ CacheManager cacheManager(RedissonClient redissonClient) throws IOException {
Map