Cache the return value, use request parameter as the key.
com.alibaba.dubbo.cache.CacheFactory
<dubbo:service cache="lru" /> <!-- method level cache --> <dubbo:service><dubbo:method cache="lru" /></dubbo:service> <!-- 缺省值设置,当<dubbo:service>没有配置cache属性时,使用此配置 --> <!-- default configuration, will take affect if cache attribute isn't configured in <dubbo:service> --> <dubbo:provider cache="xxx,yyy" />
com.alibaba.dubbo.cache.support.lru.LruCacheFactorycom.alibaba.dubbo.cache.support.threadlocal.ThreadLocalCacheFactorycom.alibaba.dubbo.cache.support.jcache.JCacheFactoryDirectory layout:
src
|-main
|-java
|-com
|-xxx
|-XxxCacheFactory.java (CacheFactory implementation)
|-resources
|-META-INF
|-dubbo
|-com.alibaba.dubbo.cache.CacheFactory (plain text file with contents: xxx=com.xxx.XxxCacheFactory)
XxxCacheFactory.java:
package com.xxx; import com.alibaba.dubbo.cache.CacheFactory; public class XxxCacheFactory implements CacheFactory { public Cache getCache(URL url, String name) { return new XxxCache(url, name); } }
XxxCacheFactory.java:
package com.xxx; import com.alibaba.dubbo.cache.Cache; public class XxxCache implements Cache { public Cache(URL url, String name) { // ... } public void put(Object key, Object value) { // ... } public Object get(Object key) { // ... } }
META-INF/dubbo/com.alibaba.dubbo.cache.CacheFactory:
xxx=com.xxx.XxxCacheFactory