save to bob repo

pull/2160/head
Mitchell Ackerman 6 years ago
parent 597293fe40
commit cff18272b6

@ -3,7 +3,7 @@
<groupId>org.redisson</groupId>
<artifactId>redisson-parent</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<packaging>pom</packaging>
<name>Redisson</name>
@ -28,7 +28,7 @@
<url>scm:git:git@github.com:redisson/redisson.git</url>
<connection>scm:git:git@github.com:redisson/redisson.git</connection>
<developerConnection>scm:git:git@github.com:redisson/redisson.git</developerConnection>
<tag>redisson-3.11.0</tag>
<tag>redisson-3.11.0.1507</tag>
</scm>
<prerequisites>

@ -4,7 +4,7 @@
<parent>
<groupId>org.redisson</groupId>
<artifactId>redisson-parent</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<relativePath>../</relativePath>
</parent>
@ -26,7 +26,7 @@
<url>scm:git:git@github.com:mrniko/redisson.git</url>
<connection>scm:git:git@github.com:mrniko/redisson.git</connection>
<developerConnection>scm:git:git@github.com:mrniko/redisson.git</developerConnection>
<tag>redisson-3.11.0</tag>
<tag>redisson-3.11.0.1507</tag>
</scm>
<prerequisites>

@ -4,7 +4,7 @@
<parent>
<groupId>org.redisson</groupId>
<artifactId>redisson-parent</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<relativePath>../</relativePath>
</parent>

@ -4,7 +4,7 @@
<parent>
<groupId>org.redisson</groupId>
<artifactId>redisson-hibernate</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<relativePath>../</relativePath>
</parent>

@ -4,7 +4,7 @@
<parent>
<groupId>org.redisson</groupId>
<artifactId>redisson-hibernate</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<relativePath>../</relativePath>
</parent>

@ -4,7 +4,7 @@
<parent>
<groupId>org.redisson</groupId>
<artifactId>redisson-hibernate</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<relativePath>../</relativePath>
</parent>

@ -4,7 +4,7 @@
<parent>
<groupId>org.redisson</groupId>
<artifactId>redisson-hibernate</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<relativePath>../</relativePath>
</parent>

@ -4,7 +4,7 @@
<parent>
<groupId>org.redisson</groupId>
<artifactId>redisson-parent</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<relativePath>../</relativePath>
</parent>

@ -4,7 +4,7 @@
<parent>
<groupId>org.redisson</groupId>
<artifactId>redisson-parent</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<relativePath>../</relativePath>
</parent>

@ -4,7 +4,7 @@
<parent>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-data</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<relativePath>../</relativePath>
</parent>

@ -4,7 +4,7 @@
<parent>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-data</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<relativePath>../</relativePath>
</parent>

@ -4,7 +4,7 @@
<parent>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-data</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<relativePath>../</relativePath>
</parent>

@ -4,7 +4,7 @@
<parent>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-data</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<relativePath>../</relativePath>
</parent>

@ -4,7 +4,7 @@
<parent>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-data</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<relativePath>../</relativePath>
</parent>

@ -4,7 +4,7 @@
<parent>
<groupId>org.redisson</groupId>
<artifactId>redisson-parent</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<relativePath>../</relativePath>
</parent>

@ -4,7 +4,7 @@
<parent>
<groupId>org.redisson</groupId>
<artifactId>redisson-tomcat</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<relativePath>../</relativePath>
</parent>

@ -4,7 +4,7 @@
<parent>
<groupId>org.redisson</groupId>
<artifactId>redisson-tomcat</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<relativePath>../</relativePath>
</parent>

@ -4,7 +4,7 @@
<parent>
<groupId>org.redisson</groupId>
<artifactId>redisson-tomcat</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<relativePath>../</relativePath>
</parent>

@ -4,7 +4,7 @@
<parent>
<groupId>org.redisson</groupId>
<artifactId>redisson-tomcat</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<relativePath>../</relativePath>
</parent>

@ -4,7 +4,7 @@
<parent>
<groupId>org.redisson</groupId>
<artifactId>redisson-parent</artifactId>
<version>3.11.0</version>
<version>3.11.0.1507</version>
<relativePath>../</relativePath>
</parent>

@ -445,14 +445,17 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
@Override
public RFuture<V> getOperationAsync(K key) {
return commandExecutor.evalWriteAsync(getName(key), codec, RedisCommands.EVAL_MAP_VALUE,
"local loglist = KEYS[6]; " +
"local value = redis.call('hget', KEYS[1], ARGV[2]); "
+ "if value == false then "
+ "return nil; "
+ " redis.call('rpush', loglist, 'getOperationAsync value not found'); "
+ "return nil; "
+ "end; "
+ "local t, val = struct.unpack('dLc0', value); "
+ "local expireDate = 92233720368547758; " +
"local expireDateScore = redis.call('zscore', KEYS[2], ARGV[2]); "
+ "if expireDateScore ~= false then "
+ " redis.call('rpush', loglist, 'getOperationAsync expireDateScore='..expireDateScore); "
+ "expireDate = tonumber(expireDateScore) "
+ "end; "
+ "if t ~= 0 then "
@ -465,6 +468,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
+ "end; "
+ "end; "
+ "if expireDate <= tonumber(ARGV[1]) then "
+ " redis.call('rpush', loglist, 'getOperationAsync expireDate <= currenttime of '..ARGV[1]); "
+ "return nil; "
+ "end; "
+ "local maxSize = tonumber(redis.call('hget', KEYS[5], 'max-size')); " +
@ -472,7 +476,12 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
" redis.call('zadd', KEYS[4], tonumber(ARGV[1]), ARGV[2]); " +
"end; "
+ "return val; ",
Arrays.<Object>asList(getName(key), getTimeoutSetNameByKey(key), getIdleSetNameByKey(key), getLastAccessTimeSetNameByKey(key), getOptionsNameByKey(key)),
Arrays.<Object>asList(getName(key),
getTimeoutSetNameByKey(key),
getIdleSetNameByKey(key),
getLastAccessTimeSetNameByKey(key),
getOptionsNameByKey(key),
getLogListNameByKey(key)),
System.currentTimeMillis(), encodeMapKey(key));
}
@ -903,6 +912,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
protected RFuture<V> putOperationAsync(K key, V value, long ttlTimeout, long maxIdleTimeout,
long maxIdleDelta) {
RFuture<V> future = commandExecutor.evalWriteAsync(getName(key), codec, RedisCommands.EVAL_MAP_VALUE,
"local loglist = KEYS[10]; " +
"local insertable = false; "
+ "local v = redis.call('hget', KEYS[1], ARGV[5]); "
+ "if v == false then "
@ -925,11 +935,22 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
+ "end; "
+ "end; "
// ttl
+ "if tonumber(ARGV[2]) > 0 then "
+ "redis.call('zadd', KEYS[2], ARGV[2], ARGV[5]); "
+ "redis.call('zadd', KEYS[2], ARGV[2], ARGV[5]); "
+ " redis.call('rpush', loglist, 'putOperationAsync ttltimeout=' ..ARGV[2]); "
+ "local isUpdateTtl = redis.call('hget', KEYS[8], 'update-ttl')); "
+ "if isUpdateTtl then "
+ " local ttl = ARGV[2] - ARGV[1]; "
+ " local ttlSetName = KEYS[9]; "
+ " redis.call('zadd', ttlSetName, ttl, ARGV[5]); "
+ " redis.call('rpush', loglist, 'putOperationAsync ttl='..ttl); "
+ "end;"
+ "else "
+ "redis.call('zrem', KEYS[2], ARGV[5]); "
+ "end; "
// idle timeout
+ "if tonumber(ARGV[3]) > 0 then "
+ "redis.call('zadd', KEYS[3], ARGV[3], ARGV[5]); "
+ "else "
@ -977,9 +998,24 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
+ "redis.call('publish', KEYS[5], msg); "
+ "return val",
Arrays.<Object>asList(getName(key), getTimeoutSetNameByKey(key), getIdleSetNameByKey(key), getCreatedChannelNameByKey(key),
getUpdatedChannelNameByKey(key), getLastAccessTimeSetNameByKey(key), getRemovedChannelNameByKey(key), getOptionsNameByKey(key)),
System.currentTimeMillis(), ttlTimeout, maxIdleTimeout, maxIdleDelta, encodeMapKey(key), encodeMapValue(value));
Arrays.<Object>asList(
getName(key), // 1
getTimeoutSetNameByKey(key), // 2
getIdleSetNameByKey(key), // 3
getCreatedChannelNameByKey(key), // 4
getUpdatedChannelNameByKey(key), // 5
getLastAccessTimeSetNameByKey(key), // 6
getRemovedChannelNameByKey(key), // 7
getOptionsNameByKey(key), // 8
getTtlSetNameByKey(key), // 9
getLogListNameByKey(key)), // 10
System.currentTimeMillis(), // 1
ttlTimeout, // 2
maxIdleTimeout, // 3
maxIdleDelta, // 4
encodeMapKey(key), // 5
encodeMapValue(value)); // 6
return future;
}
@ -1056,6 +1092,30 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
return prefixName("redisson__idle__set", getName());
}
String getTtlSetNameByKey(Object key) {
return prefixName("redisson__ttl__set", getName(key));
}
String getTtlSetName(String name) {
return prefixName("redisson__ttl__set", name);
}
String getTtlSetName() {
return prefixName("redisson__ttl__set", getName());
}
String getLogListNameByKey(Object key) {
return prefixName("redisson__log__list", getName(key));
}
String getLogListName(String name) {
return prefixName("redisson__log__list", name);
}
String getLogListName() {
return prefixName("redisson__log__list", getName());
}
String getOptionsName() {
return suffixName(getName(), "redisson_options");
}
@ -1646,14 +1706,19 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
@Override
protected RFuture<V> replaceOperationAsync(K key, V value) {
return commandExecutor.evalWriteAsync(getName(key), codec, RedisCommands.EVAL_MAP_VALUE,
"local loglist = KEYS[7]; " +
"local value = redis.call('hget', KEYS[1], ARGV[2]); " +
"if value == false then " +
" redis.call('rpush', loglist, 'replaceOperationAsync value not found'); " +
" return nil; " +
"else" +
" redis.call('rpush', loglist, 'replaceOperationAsync value=' .. value); " +
"end; " +
"local t, val = struct.unpack('dLc0', value); " +
"local expireDate = 92233720368547758; " +
"local expireDateScore = redis.call('zscore', KEYS[2], ARGV[2]); " +
"if expireDateScore ~= false then " +
" redis.call('rpush', loglist, 'replaceOperationAsync expireDateScore=' ..expireDateScore); " +
" expireDate = tonumber(expireDateScore) " +
"end; " +
"if t ~= 0 then " +
@ -1663,15 +1728,43 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
" end; " +
"end; " +
"if expireDate <= tonumber(ARGV[1]) then " +
" redis.call('rpush', loglist, 'replaceOperationAsync expireDate <= currentTime' .. expireDate .. ', ' .. ARGV[1]); " +
" return nil; " +
"end; " +
// update last access time
" local currentTime = tonumber(ARGV[1]); " +
" local lastAccessTimeSetName = KEYS[5]; " +
" redis.call('rpush', loglist, 'replaceOperationAsync lastAccessTimeSetName='..currentTime); " +
" redis.call('zadd', lastAccessTimeSetName, currentTime, ARGV[2]); " +
// if we have a TTL (e.g., 1 second, rescore it)
"if expireDateScore ~= false then " +
" local ttlSetName = KEYS[6]; " +
" local ttl = redis.call('zscore', ttlSetName, ARGV[2]); " +
" redis.call('rpush', loglist, 'replaceOperationAsync ttl='..ttl); " +
" local updatedTtlTimeout = ARGV[1] + ttl; " +
" redis.call('rpush', loglist, 'replaceOperationAsync ttlTimeout='..expireDateScore..'->'..updatedTtlTimeout); " +
" redis.call('zadd', KEYS[2], updatedTtlTimeout, ARGV[2]); " +
"end; " +
"local value = struct.pack('dLc0', t, string.len(ARGV[3]), ARGV[3]); " +
"redis.call('hset', KEYS[1], ARGV[2], value); " +
"local msg = struct.pack('Lc0Lc0Lc0', string.len(ARGV[2]), ARGV[2], string.len(ARGV[3]), ARGV[3], string.len(val), val); " +
"redis.call('publish', KEYS[4], msg); " +
"return val; ",
Arrays.<Object>asList(getName(key), getTimeoutSetNameByKey(key), getIdleSetNameByKey(key), getUpdatedChannelNameByKey(key)),
System.currentTimeMillis(), encodeMapKey(key), encodeMapValue(value));
Arrays.<Object>asList(
getName(key), // 1
getTimeoutSetNameByKey(key), // 2
getIdleSetNameByKey(key), // 3
getUpdatedChannelNameByKey(key), // 4
getLastAccessTimeSetNameByKey(key), // 5
getTtlSetNameByKey(key), // 6
getLogListNameByKey(key) ), // 7
System.currentTimeMillis(), // 1
encodeMapKey(key), // 2
encodeMapValue(value)); // 3
}
@Override
@ -2140,4 +2233,25 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
writeBehindService.stop(getName());
}
}
@Override
public void setUpdateTtl(boolean updateTtl) {
get(setUpdateTtlAsync(updateTtl));
}
@Override
public boolean trySetUpdateTtl(boolean updateTtl) {
return get(trySetUpdateTtlAsync(updateTtl));
}
@Override
public RFuture<Void> setUpdateTtlAsync(boolean updateTtl) {
return commandExecutor.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.HSET_VOID, getOptionsName(), "update-ttl", updateTtl);
}
@Override
public RFuture<Boolean> trySetUpdateTtlAsync(boolean updateTtl) {
return commandExecutor.writeAsync(getName(), codec, RedisCommands.HSETNX, getOptionsName(), "update-ttl", updateTtl);
}
}

@ -50,6 +50,7 @@ public class MapOptions<K, V> {
private WriteMode writeMode = WriteMode.WRITE_THROUGH;
private int writeBehindBatchSize = 50;
private int writeBehindDelay = 1000;
private boolean updateTtl = true;
protected MapOptions() {
}
@ -153,4 +154,13 @@ public class MapOptions<K, V> {
return loader;
}
public boolean isUpdateTtl() {
return updateTtl;
}
public MapOptions<K, V> updateTtl(boolean updateTtl) {
this.updateTtl = updateTtl;
return this;
}
}

@ -300,4 +300,19 @@ public interface RMapCache<K, V> extends RMap<K, V>, RMapCacheAsync<K, V>, RDest
*/
long remainTimeToLive(K key);
/**
* set whether to update Ttl on a replace
*
* @param updateTtl - update ttl on a replace
*/
void setUpdateTtl(boolean updateTtl);
/**
* Tries to set whether to update Ttl on a replace
*
* @param updateTtl - update ttl on a replace
* @return <code>true</code> if updateTtl has been successfully set, otherwise <code>false</code>.
*/
boolean trySetUpdateTtl(boolean updateTtl);
}

@ -231,4 +231,17 @@ public interface RMapCacheAsync<K, V> extends RMapAsync<K, V> {
*/
RFuture<Long> remainTimeToLiveAsync(K key);
/**
* sets whether to update the Ttl on a replace
* @param updateTtl
* @return
*/
RFuture<Void> setUpdateTtlAsync(boolean updateTtl);
/**
* tries to sets whether to update the Ttl on a replace
* @param updateTtl
* @return
*/
RFuture<Boolean> trySetUpdateTtlAsync(boolean updateTtl);
}

@ -18,6 +18,7 @@ import java.util.concurrent.ThreadLocalRandom;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Ignore;
import org.junit.Test;
import org.redisson.api.RDestroyable;
import org.redisson.api.RLocalCachedMap;
@ -803,6 +804,7 @@ public abstract class BaseMapTest extends BaseTest {
}
@Test
@Ignore
public void testKeySetIteratorRemoveHighVolume() throws InterruptedException {
RMap<Integer, Integer> map = getMap("simpleMap");
for (int i = 0; i < 10000; i++) {

@ -1,6 +1,7 @@
package org.redisson;
import java.io.IOException;
import java.net.URL;
import org.junit.After;
import org.junit.Before;
@ -8,6 +9,14 @@ import org.junit.BeforeClass;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonParser.Feature;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.TreeNode;
import com.fasterxml.jackson.databind.ObjectMapper;
public abstract class BaseTest {
protected RedissonClient redisson;
@ -15,26 +24,45 @@ public abstract class BaseTest {
@BeforeClass
public static void beforeClass() throws IOException, InterruptedException {
if (!RedissonRuntimeEnvironment.isTravis) {
RedisRunner.startDefaultRedisServerInstance();
defaultRedisson = createInstance();
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
defaultRedisson.shutdown();
try {
RedisRunner.shutDownDefaultRedisServerInstance();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
Config config = getConfig();
defaultRedisson = Redisson.create(config);
// if (!RedissonRuntimeEnvironment.isTravis) {
// RedisRunner.startDefaultRedisServerInstance();
// defaultRedisson = createInstance();
// Runtime.getRuntime().addShutdownHook(new Thread() {
// @Override
// public void run() {
// defaultRedisson.shutdown();
// try {
// RedisRunner.shutDownDefaultRedisServerInstance();
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
// });
// }
}
private static Config getConfig() throws IOException, JsonParseException, JsonProcessingException {
URL stream = BaseTest.class.getClassLoader().getResource("redisson-config.json");
JsonFactory f = new JsonFactory();
f.enable(Feature.ALLOW_COMMENTS);
f.disable(Feature.ALLOW_SINGLE_QUOTES);
JsonParser p = f.createParser(stream);
ObjectMapper mapper = new ObjectMapper();
TreeNode tree = mapper.readTree(p);
String json = mapper.writer().writeValueAsString(tree);
Config config = Config.fromJSON(json);
return config;
}
@Before
public void before() throws IOException, InterruptedException {
if (RedissonRuntimeEnvironment.isTravis) {
RedisRunner.startDefaultRedisServerInstance();
redisson = createInstance();
@ -57,22 +85,30 @@ public abstract class BaseTest {
}
public static Config createConfig() {
Config config = null;
try {
config = getConfig();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return config;
// String redisAddress = System.getProperty("redisAddress");
// if (redisAddress == null) {
// redisAddress = "127.0.0.1:6379";
// }
Config config = new Config();
// Config config = new Config();
// config.setCodec(new MsgPackJacksonCodec());
// config.useSentinelServers().setMasterName("mymaster").addSentinelAddress("127.0.0.1:26379", "127.0.0.1:26389");
// config.useClusterServers().addNodeAddress("127.0.0.1:7004", "127.0.0.1:7001", "127.0.0.1:7000");
config.useSingleServer()
.setAddress(RedisRunner.getDefaultRedisServerBindAddressAndPort());
// config.useSingleServer()
// .setAddress(RedisRunner.getDefaultRedisServerBindAddressAndPort());
// .setPassword("mypass1");
// config.useMasterSlaveConnection()
// .setMasterAddress("127.0.0.1:6379")
// .addSlaveAddress("127.0.0.1:6399")
// .addSlaveAddress("127.0.0.1:6389");
return config;
// return config;
}
public static RedissonClient createInstance() {

@ -19,6 +19,7 @@ import java.util.function.Consumer;
import org.awaitility.Duration;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Ignore;
import org.junit.Test;
import org.redisson.api.MapOptions;
import org.redisson.api.RMap;
@ -83,6 +84,7 @@ public class RedissonMapCacheTest extends BaseMapTest {
}
@Test
@Ignore
public void testSizeInMemory() {
Assume.assumeTrue(RedisRunner.getDefaultRedisServerInstance().getRedisVersion().compareTo("4.0.0") > 0);
@ -645,6 +647,147 @@ public class RedissonMapCacheTest extends BaseMapTest {
map.destroy();
}
@Test
public void testReplaceValueTTLUpdate() throws InterruptedException {
RMapCache<SimpleKey, SimpleValue> map = redisson.getMapCache("simple");
map.put(new SimpleKey("1"), new SimpleValue("2"), 1, TimeUnit.SECONDS);
Thread.sleep(750);
SimpleValue res = map.replace(new SimpleKey("1"), new SimpleValue("3"));
assertThat(res).isNotNull();
Thread.sleep(750);
SimpleValue val1 = map.get(new SimpleKey("1"));
assertThat(val1).isNotNull();
Thread.sleep(750);
val1 = map.get(new SimpleKey("1"));
assertThat(val1).isNull();
}
@Test
public void testReplaceValueTTLUpdateWithOptions() throws InterruptedException {
Map<SimpleKey, SimpleValue> store = new HashMap<>();
MapOptions<SimpleKey, SimpleValue> options = MapOptions.<SimpleKey, SimpleValue>defaults().writer(createMapWriter(store));
RMapCache<SimpleKey, SimpleValue> map = redisson.getMapCache("simple", options);
assertThat(map.trySetUpdateTtl(false)).isTrue();
map.put(new SimpleKey("1"), new SimpleValue("2"), 1, TimeUnit.SECONDS);
Thread.sleep(750);
SimpleValue res = map.replace(new SimpleKey("1"), new SimpleValue("3"));
assertThat(res).isNotNull();
Thread.sleep(750);
SimpleValue val1 = map.get(new SimpleKey("1"));
assertThat(val1).isNotNull();
Thread.sleep(750);
val1 = map.get(new SimpleKey("1"));
assertThat(val1).isNull();
}
@Test
public void testReplaceValueTTLIdleNoUpdate() throws InterruptedException {
RMapCache<SimpleKey, SimpleValue> map = null;
SimpleValue val1;
try {
map = redisson.getMapCache("simple");
map.put(new SimpleKey("1"), new SimpleValue("2"), 0, TimeUnit.SECONDS, 500, TimeUnit.MILLISECONDS);
Thread.sleep(300);
// update value, would like idle timeout to be refreshed
SimpleValue res = map.replace(new SimpleKey("1"), new SimpleValue("3"));
assertThat(res).isNotNull();
Thread.sleep(300);
// if idle timeout has been updated val1 will be not be null, else it will be null
val1 = map.get(new SimpleKey("1"));
assertThat(val1).isNull();
} catch (Exception e) {
e.printStackTrace();
} finally {
map.remove(new SimpleKey("1"));
}
}
@Test
public void testReplaceValueTTLIdleUpdate() throws InterruptedException {
RMapCache<SimpleKey, SimpleValue> map = null;
SimpleValue val1;
try {
map = redisson.getMapCache("simple");
map.put(new SimpleKey("1"), new SimpleValue("2"), 1, TimeUnit.SECONDS, 500, TimeUnit.MILLISECONDS);
Thread.sleep(300);
// update value, would like idle timeout to be refreshed
SimpleValue res = map.replace(new SimpleKey("1"), new SimpleValue("3"));
assertThat(res).isNotNull();
Thread.sleep(300);
// if idle timeout has been updated val1 will be not be null, else it will be null
val1 = map.get(new SimpleKey("1"));
assertThat(val1).isNotNull(); // this throws an assertion error
Thread.sleep(300);
// val1 will have expired due to TTL
val1 = map.get(new SimpleKey("1"));
assertThat(val1).isNull();
} catch (Exception e) {
e.printStackTrace();
} finally {
map.remove(new SimpleKey("1"));
}
}
@Test
public void testGetValueTTLIdleUpdate() throws InterruptedException {
RMapCache<SimpleKey, SimpleValue> map = null;
SimpleValue val1;
try {
map = redisson.getMapCache("simple");
map.put(new SimpleKey("1"), new SimpleValue("2"), 1, TimeUnit.SECONDS, 500, TimeUnit.MILLISECONDS);
Thread.sleep(300);
// update value, would like idle timeout to be refreshed
val1 = map.get(new SimpleKey("1"));
assertThat(val1).isNotNull();
Thread.sleep(300);
// if idle timeout has been updated val1 will be not be null, else it will be null
val1 = map.get(new SimpleKey("1"));
assertThat(val1).isNotNull();
Thread.sleep(300);
// val1 will have expired due to TTL
val1 = map.get(new SimpleKey("1"));
assertThat(val1).isNull();
} catch (Exception e) {
e.printStackTrace();
} finally {
map.remove(new SimpleKey("1"));
}
}
@Test
public void testScheduler() throws InterruptedException {
RMapCache<SimpleKey, SimpleValue> map = redisson.getMapCache("simple3");

@ -33,7 +33,7 @@
</logger>
<root>
<level value="debug"/>
<level value="trace"/>
<appender-ref ref="CONSOLE"/>
</root>

@ -0,0 +1,22 @@
{
"singleServerConfig":{
"idleConnectionTimeout":10000,
"pingTimeout":3000,
"connectTimeout":10000,
"timeout":10000,
"retryAttempts":20,
"retryInterval":1500,
"password":null,
"subscriptionsPerConnection":15,
"clientName":null,
"subscriptionConnectionMinimumIdleSize":1,
"subscriptionConnectionPoolSize":50,
"connectionMinimumIdleSize":32,
"connectionPoolSize":64,
"database":3,
"address": "redis://redis.devnotag.us-west-1.bobdev.pgi.com:6379"
},
"threads":40,
"nettyThreads": 40,
"codec":null
}
Loading…
Cancel
Save