Search in sources :

Example 1 with ThreadLocalCache

use of org.apache.dubbo.cache.support.threadlocal.ThreadLocalCache in project dubbo by alibaba.

the class CacheTest method testCacheProvider.

@Test
public void testCacheProvider() throws Exception {
    CacheFactory cacheFactory = ExtensionLoader.getExtensionLoader(CacheFactory.class).getAdaptiveExtension();
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("findCache.cache", "threadlocal");
    URL url = new URL("dubbo", "127.0.0.1", 29582, "org.apache.dubbo.config.cache.CacheService", parameters);
    Invocation invocation = new RpcInvocation("findCache", CacheService.class.getName(), "", new Class[] { String.class }, new String[] { "0" }, null, null, null);
    Cache cache = cacheFactory.getCache(url, invocation);
    assertTrue(cache instanceof ThreadLocalCache);
}
Also used : RpcInvocation(org.apache.dubbo.rpc.RpcInvocation) Invocation(org.apache.dubbo.rpc.Invocation) RpcInvocation(org.apache.dubbo.rpc.RpcInvocation) HashMap(java.util.HashMap) CacheFactory(org.apache.dubbo.cache.CacheFactory) URL(org.apache.dubbo.common.URL) Cache(org.apache.dubbo.cache.Cache) ThreadLocalCache(org.apache.dubbo.cache.support.threadlocal.ThreadLocalCache) ThreadLocalCache(org.apache.dubbo.cache.support.threadlocal.ThreadLocalCache) Test(org.junit.jupiter.api.Test)

Aggregations

HashMap (java.util.HashMap)1 Cache (org.apache.dubbo.cache.Cache)1 CacheFactory (org.apache.dubbo.cache.CacheFactory)1 ThreadLocalCache (org.apache.dubbo.cache.support.threadlocal.ThreadLocalCache)1 URL (org.apache.dubbo.common.URL)1 Invocation (org.apache.dubbo.rpc.Invocation)1 RpcInvocation (org.apache.dubbo.rpc.RpcInvocation)1 Test (org.junit.jupiter.api.Test)1