缓存扩展
扩展说明
使用请求参数作为键缓存返回结果。
扩展点
org.apache.dubbo.cache.CacheFactory
扩展配置
<dubbo:service cache="lru" />
<!-- method level cache -->
<dubbo:service><dubbo:method cache="lru" /></dubbo:service>
<!-- The default value setting, when <dubbo:service> does not configure the cache attribute, use this configuration -->
<dubbo:provider cache="xxx,yyy" />
已知扩展
org.apache.dubbo.cache.support.lru.LruCacheFactory
org.apache.dubbo.cache.support.threadlocal.ThreadLocalCacheFactory
org.apache.dubbo.cache.support.jcache.JCacheFactory
扩展示例
Maven 项目结构
src
|-main
|-java
|-com
|-xxx
|-XxxCacheFactory.java (implements the CacheFactory interface)
|-resources
|-META-INF
|-dubbo
|-org.apache.dubbo.cache.CacheFactory (plain text file, content: xxx=com.xxx.XxxCacheFactory)
XxxCacheFactory.java
package com.xxx;
import org.apache.dubbo.cache.CacheFactory;
public class XxxCacheFactory implements CacheFactory {
public Cache getCache(URL url, String name) {
return new XxxCache(url, name);
}
}
XxxCache.java
package com.xxx;
import org.apache.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/org.apache.dubbo.cache.CacheFactory
xxx=com.xxx.XxxCacheFactory
上次修改时间:2023 年 1 月 2 日: 增强英文文档 (#1798) (95a9f4f6c1c)