Dubbo学习(十一):结果缓存

来源:互联网 发布:姚明05-06赛季数据 编辑:程序博客网 时间:2024/06/09 18:45

  为什么要用到结果缓存,主要是用于加速热门数据的访问速度,Dubbo提供声明式缓存,以减少用户加缓存的工作量

  缓存的应用非常广泛,为了提高数据访问的速度。Dubbo也不例外,它提供了声明式缓存,以减少用户加缓存的工作量。

一、Dubbo中缓存策略

  • lru 基于最近最少使用原则删除多余缓存,保持最热的数据被缓存。
  • threadlocal 当前线程缓存,比如一个页面渲染,用到很多portal,每个portal都要去查用户信息,通过线程缓存,可以减少这种多余访问。
  • jcache 与JSR107集成,可以桥接各种缓存实现。
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.     xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"  
  5.     xsi:schemaLocation="http://www.springframework.org/schema/beans  
  6.         http://www.springframework.org/schema/beans/spring-beans.xsd  
  7.         http://code.alibabatech.com/schema/dubbo  
  8.         http://code.alibabatech.com/schema/dubbo/dubbo.xsd  
  9.         ">       
  10.     <!-- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样  192.9.145.19:2181,192.9.145.19:2182,192.9.145.19:2183-->  
  11.     <dubbo:application name="cache-consumer" />       <!-- 使用multicast广播注册中心暴露发现服务地址 -->  
  12.     <dubbo:registry  protocol="zookeeper"  address="192.168.24.140:2181" />         <!-- 生成远程服务代理,可以和本地bean一样使用demoService -->  
  13.     <dubbo:reference id="cacheService" interface="com.tgb.cacheService.CacheService" cache="true" />  
  14. </beans>  

0 0
原创粉丝点击