Search in sources :

Example 11 with Cache

use of org.apache.dubbo.cache.Cache 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"));
}
Also used : RpcInvocation(org.apache.dubbo.rpc.RpcInvocation) Invocation(org.apache.dubbo.rpc.Invocation) RpcInvocation(org.apache.dubbo.rpc.RpcInvocation) AbstractCacheFactory(org.apache.dubbo.cache.support.AbstractCacheFactory) URL(org.apache.dubbo.common.URL) Cache(org.apache.dubbo.cache.Cache) Test(org.junit.jupiter.api.Test) AbstractCacheFactoryTest(org.apache.dubbo.cache.support.AbstractCacheFactoryTest)

Example 12 with Cache

use of org.apache.dubbo.cache.Cache in project dubbo by alibaba.

the class LruCacheFactoryTest method testLruCacheFactory.

@Test
public void testLruCacheFactory() throws Exception {
    Cache cache = super.constructCache();
    assertThat(cache instanceof LruCache, is(true));
}
Also used : Cache(org.apache.dubbo.cache.Cache) Test(org.junit.jupiter.api.Test) AbstractCacheFactoryTest(org.apache.dubbo.cache.support.AbstractCacheFactoryTest)

Aggregations

Cache (org.apache.dubbo.cache.Cache)12 Test (org.junit.jupiter.api.Test)10 AbstractCacheFactoryTest (org.apache.dubbo.cache.support.AbstractCacheFactoryTest)9 URL (org.apache.dubbo.common.URL)4 Invocation (org.apache.dubbo.rpc.Invocation)4 RpcInvocation (org.apache.dubbo.rpc.RpcInvocation)4 AbstractCacheFactory (org.apache.dubbo.cache.support.AbstractCacheFactory)3 HashMap (java.util.HashMap)1 CacheFactory (org.apache.dubbo.cache.CacheFactory)1 ThreadLocalCache (org.apache.dubbo.cache.support.threadlocal.ThreadLocalCache)1 AsyncRpcResult (org.apache.dubbo.rpc.AsyncRpcResult)1 Result (org.apache.dubbo.rpc.Result)1