use of org.redisson.codec.MsgPackJacksonCodec in project redisson by redisson.
the class RedissonMapCacheTest method testScheduler.
@Test
public void testScheduler() throws InterruptedException {
RMapCache<SimpleKey, SimpleValue> map = redisson.getMapCache("simple3", new MsgPackJacksonCodec());
Assert.assertNull(map.get(new SimpleKey("33")));
map.put(new SimpleKey("33"), new SimpleValue("44"), 5, TimeUnit.SECONDS);
map.put(new SimpleKey("10"), new SimpleValue("32"), 5, TimeUnit.SECONDS, 2, TimeUnit.SECONDS);
map.put(new SimpleKey("01"), new SimpleValue("92"), 0, null, 2, TimeUnit.SECONDS);
Assert.assertEquals(3, map.size());
Thread.sleep(11000);
Assert.assertEquals(0, map.size());
}
use of org.redisson.codec.MsgPackJacksonCodec in project redisson by redisson.
the class RedissonMapCacheTest method testPutGet.
@Test
public void testPutGet() throws InterruptedException {
RMapCache<SimpleKey, SimpleValue> map = redisson.getMapCache("simple04", new MsgPackJacksonCodec());
Assert.assertNull(map.get(new SimpleKey("33")));
map.put(new SimpleKey("33"), new SimpleValue("44"), 2, TimeUnit.SECONDS);
SimpleValue val1 = map.get(new SimpleKey("33"));
Assert.assertEquals("44", val1.getValue());
Thread.sleep(1000);
Assert.assertEquals(1, map.size());
SimpleValue val2 = map.get(new SimpleKey("33"));
Assert.assertEquals("44", val2.getValue());
Assert.assertEquals(1, map.size());
Thread.sleep(1000);
Assert.assertNull(map.get(new SimpleKey("33")));
}
use of org.redisson.codec.MsgPackJacksonCodec in project redisson by redisson.
the class RedissonMapCacheReactiveTest method testContainsValue.
@Test
public void testContainsValue() throws InterruptedException {
RMapCacheReactive<SimpleKey, SimpleValue> map = redisson.getMapCache("simple31", new MsgPackJacksonCodec());
Assert.assertFalse(sync(map.containsValue(new SimpleValue("34"))));
sync(map.put(new SimpleKey("33"), new SimpleValue("44"), 1, TimeUnit.SECONDS));
Assert.assertTrue(sync(map.containsValue(new SimpleValue("44"))));
Assert.assertFalse(sync(map.containsValue(new SimpleValue("34"))));
Thread.sleep(1000);
Assert.assertFalse(sync(map.containsValue(new SimpleValue("44"))));
}
Aggregations