use of org.apache.dubbo.cache.support.AbstractCacheFactory in project dubbo by alibaba.
the class JCacheFactoryTest method testJCacheGetExpired.
@Test
public void testJCacheGetExpired() throws Exception {
URL url = URL.valueOf("test://test:12/test?cache=jacache&cache.write.expire=1");
AbstractCacheFactory cacheFactory = getCacheFactory();
Invocation invocation = new RpcInvocation();
Cache cache = cacheFactory.getCache(url, invocation);
cache.put("testKey", "testValue");
Thread.sleep(10);
assertNull(cache.get("testKey"));
}
use of org.apache.dubbo.cache.support.AbstractCacheFactory in project dubbo by alibaba.
the class ExpiringCacheFactoryTest method testExpiringCacheUnExpired.
@Test
public void testExpiringCacheUnExpired() throws Exception {
URL url = URL.valueOf("test://test:12/test?cache=expiring&cache.seconds=0&cache.interval=1");
AbstractCacheFactory cacheFactory = getCacheFactory();
Invocation invocation = new RpcInvocation();
Cache cache = cacheFactory.getCache(url, invocation);
cache.put("testKey", "testValue");
Thread.sleep(1100);
assertNotNull(cache.get("testKey"));
}
use of org.apache.dubbo.cache.support.AbstractCacheFactory in project dubbo by alibaba.
the class ExpiringCacheFactoryTest method testExpiringCacheGetExpired.
@Test
public void testExpiringCacheGetExpired() throws Exception {
URL url = URL.valueOf("test://test:12/test?cache=expiring&cache.seconds=1&cache.interval=1");
AbstractCacheFactory cacheFactory = getCacheFactory();
Invocation invocation = new RpcInvocation();
Cache cache = cacheFactory.getCache(url, invocation);
cache.put("testKey", "testValue");
Thread.sleep(2100);
assertNull(cache.get("testKey"));
}
Aggregations