Search in sources :

Example 1 with CacheFactory

use of com.alibaba.dubbo.cache.CacheFactory 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, "com.alibaba.dubbo.config.cache.CacheService", parameters);
    Invocation invocation = new RpcInvocation("findCache", new Class[] { String.class }, new String[] { "0" }, null, null);
    Cache cache = cacheFactory.getCache(url, invocation);
    assertTrue(cache instanceof ThreadLocalCache);
}
Also used : RpcInvocation(com.alibaba.dubbo.rpc.RpcInvocation) RpcInvocation(com.alibaba.dubbo.rpc.RpcInvocation) Invocation(com.alibaba.dubbo.rpc.Invocation) HashMap(java.util.HashMap) CacheFactory(com.alibaba.dubbo.cache.CacheFactory) URL(com.alibaba.dubbo.common.URL) ThreadLocalCache(com.alibaba.dubbo.cache.support.threadlocal.ThreadLocalCache) Cache(com.alibaba.dubbo.cache.Cache) ThreadLocalCache(com.alibaba.dubbo.cache.support.threadlocal.ThreadLocalCache) Test(org.junit.Test)

Aggregations

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