类 CacheFilter
- java.lang.Object
-
- org.apache.dubbo.cache.filter.CacheFilter
-
- 所有已实现的接口:
Filter
@Activate(group={"consumer","provider"}, value="cache") public class CacheFilter extends Object implements Filter
CacheFilter is a core component of dubbo.Enabling cache key of service,method,consumer or provider dubbo will cache method return value. Along with cache key we need to configure cache type. Dubbo default implemented cache types are- lru
- threadlocal
- jcache
- expiring
e.g. 1)<dubbo:service cache="lru" /> 2)<dubbo:service /> <dubbo:method name="method2" cache="threadlocal" /> <dubbo:service/> 3)<dubbo:provider cache="expiring" /> 4)<dubbo:consumer cache="jcache" /> If cache type is defined in method level then method level type will get precedence. According to above provided example, if service has two method, method1 and method2, method2 will have cache type as threadlocal where others will be backed by lru
-
-
嵌套类概要
-
从接口继承的嵌套类/接口 org.apache.dubbo.rpc.Filter
Filter.Listener
-
-
构造器概要
构造器 构造器 说明 CacheFilter()
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 Resultinvoke(Invoker<?> invoker, Invocation invocation)If cache is configured, dubbo will invoke method on each method call.voidsetCacheFactory(CacheFactory cacheFactory)Dubbo will populate and set the cache factory instance based on service/method/consumer/provider configured cache attribute value.
-
-
-
方法详细资料
-
setCacheFactory
public void setCacheFactory(CacheFactory cacheFactory)
Dubbo will populate and set the cache factory instance based on service/method/consumer/provider configured cache attribute value. Dubbo will search for the class name implementing configured cache in file org.apache.dubbo.cache.CacheFactory under META-INF sub folders.- 参数:
cacheFactory- instance of CacheFactory based on cache type
-
invoke
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException
If cache is configured, dubbo will invoke method on each method call. If cache value is returned by cache store then it will return otherwise call the remote method and return value. If remote method's return value has error then it will not cache the value.- 指定者:
invoke在接口中Filter- 参数:
invoker- serviceinvocation- invocation.- 返回:
- Cache returned value if found by the underlying cache store. If cache miss it will call target method.
- 抛出:
RpcException
-
-