W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
用請求參數(shù)作為 key,緩存返回結(jié)果。
org.apache.dubbo.cache.CacheFactory
<dubbo:service cache="lru" />
<!-- 方法級緩存 -->
<dubbo:service><dubbo:method cache="lru" /></dubbo:service>
<!-- 缺省值設(shè)置,當(dāng)<dubbo:service>沒有配置cache屬性時,使用此配置 -->
<dubbo:provider cache="xxx,yyy" />
Maven 項目結(jié)構(gòu):
src
|-main
|-java
|-com
|-xxx
|-XxxCacheFactory.java (實現(xiàn)CacheFactory接口)
|-resources
|-META-INF
|-dubbo
|-org.apache.dubbo.cache.CacheFactory (純文本文件,內(nèi)容為: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
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: