当前位置: 首页 > news >正文

wordpress专业主题百度关键词搜索引擎排名优化

wordpress专业主题,百度关键词搜索引擎排名优化,如何做网站性能优化,腾讯企业邮箱免费版本文将详细介绍如何使用CacheFrontend和Caffeine来实现二级缓存。 1. 简介 CacheFrontend: 是一种用于缓存的前端组件或服务。通俗的讲:该接口可以实现本地缓存与redis自动同步,如果本地缓存(JVM级)有数据,则直接从本…

本文将详细介绍如何使用CacheFrontend和Caffeine来实现二级缓存。

1. 简介

CacheFrontend: 是一种用于缓存的前端组件或服务。通俗的讲:该接口可以实现本地缓存与redis自动同步,如果本地缓存(JVM级)有数据,则直接从本地缓存中返回数据。否则从redis获取。

CacheFrontend的工作方式通常涉及以下两个方面:

  • 数据存储:CacheFrontend会将从后端(Redis)获取的数据存储在本地缓存中。这样,在后续请求中,如果相同的数据被请求,CacheFrontend可以直接从本地缓存中返回,而无需再次访问后端存储(Redis)。这减少了对后端存储的访问次数,提高了响应速度。

  • 数据更新和失效:当后端存储中的数据发生变化时,CacheFrontend需要相应地更新本地缓存中的数据。它可以通过主动监测后端存储的变化。

通过使用CacheFrontend,应用程序可以减轻后端存储的负载,提高系统的性能和可扩展性,从而改善用户体验。

CacheFrontend是由 Lettuce 提供,Lettuce 提供了 ClientSideCaching 实现,在该实现类中接受一个CacheAccessor缓存访问器。我们可以根据具体需要实现自己的缓存访问器。本文将自定义CacheAccessor结合Caffeine实现缓存策略。

2. 实战案例

2.1 依赖管理

<!--高性能本地缓存实现-->
<dependency><groupId>com.github.ben-manes.caffeine</groupId><artifactId>caffeine</artifactId>
</dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>

2.2 配置文件

spring:redis:host: localhostpassword: xxxooodatabase: 10port: 6379

2.2 配置

本地缓存配置
@Bean
public Cache<String, String> localCache() {return  Caffeine.newBuilder()// 初始容量.initialCapacity(100).maximumSize(1000).build() ;
}
RedisClient配置
@Bean
public RedisClient redisClient(RedisProperties props) {RedisURI clientResources = RedisURI.Builder.redis(props.getHost(), props.getPort()).withPassword(props.getPassword().toCharArray()).withDatabase(props.getDatabase()).build() ;RedisClient client = RedisClient.create(clientResources) ;return client ;
}

RedisProperties是系统内部自动注册的Bean。

缓存前端配置CacheFrontend
@Beanpublic CacheFrontend<String, String> cacheFrontend(RedisClient redisClient, Cache<String, String> localCache) {StatefulRedisConnection<String, String> connection = redisClient.connect() ;// 添加监听器,当缓存失效后会被监听到。connection.addListener(new PushListener() {@Overridepublic void onPushMessage(PushMessage message) {String type = message.getType() ;if ("invalidate".equals(type)) {System.out.println("...") ;}List<Object> contents = message.getContent() ;Object content = contents.get(0);if (content instanceof ByteBuffer) {ByteBuffer buf = (ByteBuffer) content ;System.out.printf("response content: %s%n", StringCodec.UTF8.decodeValue(buf)) ;}}}) ;// 缓存访问器CacheAccessor<String, String> cacheAccessor = new CacheAccessor<String, String>() {@Overridepublic String get(String key) {@NullableString present = localCache.getIfPresent(key) ;System.out.printf("get operator: %s%n", present) ;return present ;}@Overridepublic void put(String key, String value) {localCache.put(key, value) ;System.out.printf("put operator: key = %s, value = %s%n", key, value) ;}@Overridepublic void evict(String key) {localCache.invalidate(key) ;System.out.printf("evict operator: %s%n", key) ;}};CacheFrontend<String, String> frontend = ClientSideCaching.enable(cacheAccessor, connection,TrackingArgs.Builder.enabled()) ;return frontend ;}

总结:通过本地缓存和Redis缓存可以带来诸多好处,如提高系统性能、减轻数据库压力、支持高并发等。通过合理配置和管理本地缓存与Redis缓存,可以优化应用程序的性能,提高系统的稳定性和可用性。在实际应用中,根据业务需求选择合适的缓存策略和数据结构,并进行持续的性能监控和调优,是确保系统高效运行的关键。


文章转载自:
http://dinncopietas.ssfq.cn
http://dinncophotoradiogram.ssfq.cn
http://dinncohypersensitize.ssfq.cn
http://dinncosnapper.ssfq.cn
http://dinncothor.ssfq.cn
http://dinncoyorkshireman.ssfq.cn
http://dinncomicrofolio.ssfq.cn
http://dinncohabsburg.ssfq.cn
http://dinncopyknosis.ssfq.cn
http://dinncoallotropy.ssfq.cn
http://dinncouncomplimentary.ssfq.cn
http://dinnconomism.ssfq.cn
http://dinncoturf.ssfq.cn
http://dinncoblusher.ssfq.cn
http://dinncocaviler.ssfq.cn
http://dinncolinden.ssfq.cn
http://dinncogalabia.ssfq.cn
http://dinncononstop.ssfq.cn
http://dinncohellbox.ssfq.cn
http://dinncoreligiosity.ssfq.cn
http://dinncodeadening.ssfq.cn
http://dinncoscottish.ssfq.cn
http://dinncotriose.ssfq.cn
http://dinncobypath.ssfq.cn
http://dinncothermophilic.ssfq.cn
http://dinncoconciliatory.ssfq.cn
http://dinncobacchant.ssfq.cn
http://dinncoleukovirus.ssfq.cn
http://dinncovandyke.ssfq.cn
http://dinncodiapir.ssfq.cn
http://dinnconickel.ssfq.cn
http://dinncodemo.ssfq.cn
http://dinncovaginotomy.ssfq.cn
http://dinncoomnivorously.ssfq.cn
http://dinncoswartzite.ssfq.cn
http://dinncodeterminant.ssfq.cn
http://dinncoconvertor.ssfq.cn
http://dinncolockjaw.ssfq.cn
http://dinncogulfweed.ssfq.cn
http://dinncobrett.ssfq.cn
http://dinncomarri.ssfq.cn
http://dinncocessative.ssfq.cn
http://dinncoisland.ssfq.cn
http://dinncogoyim.ssfq.cn
http://dinncoleon.ssfq.cn
http://dinncoconvey.ssfq.cn
http://dinncohermit.ssfq.cn
http://dinncoallantoid.ssfq.cn
http://dinncolombrosian.ssfq.cn
http://dinncoprogress.ssfq.cn
http://dinncozealousness.ssfq.cn
http://dinncopreside.ssfq.cn
http://dinncoatrioventricular.ssfq.cn
http://dinncocervelas.ssfq.cn
http://dinncoharijan.ssfq.cn
http://dinncobummel.ssfq.cn
http://dinncomacadamize.ssfq.cn
http://dinncodegauss.ssfq.cn
http://dinncopantograph.ssfq.cn
http://dinncosawbones.ssfq.cn
http://dinncocoeternal.ssfq.cn
http://dinncoammonotelism.ssfq.cn
http://dinncoarchean.ssfq.cn
http://dinncophyllome.ssfq.cn
http://dinncogrimly.ssfq.cn
http://dinncopetitory.ssfq.cn
http://dinncodiplophase.ssfq.cn
http://dinncoexpostulatory.ssfq.cn
http://dinncostreptococcus.ssfq.cn
http://dinncosaturnism.ssfq.cn
http://dinncoamylum.ssfq.cn
http://dinncoappressed.ssfq.cn
http://dinncowiseass.ssfq.cn
http://dinncodenticulate.ssfq.cn
http://dinncorete.ssfq.cn
http://dinncoserving.ssfq.cn
http://dinncorotochute.ssfq.cn
http://dinncocorrectness.ssfq.cn
http://dinncomesosphere.ssfq.cn
http://dinnconifelheim.ssfq.cn
http://dinncoinerrant.ssfq.cn
http://dinncoendothelioid.ssfq.cn
http://dinncopivotal.ssfq.cn
http://dinncorosarium.ssfq.cn
http://dinncoorthotic.ssfq.cn
http://dinncocrossfire.ssfq.cn
http://dinncooceanologic.ssfq.cn
http://dinncoremarkable.ssfq.cn
http://dinncocalix.ssfq.cn
http://dinncoscatheless.ssfq.cn
http://dinncodipcoat.ssfq.cn
http://dinncoisolationism.ssfq.cn
http://dinncoendocrinotherapy.ssfq.cn
http://dinncobasilar.ssfq.cn
http://dinncometalepsis.ssfq.cn
http://dinncohexamethonium.ssfq.cn
http://dinncotorpid.ssfq.cn
http://dinncotransspecific.ssfq.cn
http://dinncohydraemic.ssfq.cn
http://dinncolees.ssfq.cn
http://www.dinnco.com/news/162196.html

相关文章:

  • 哪些网站做魔兽地图怎么做网络营销
  • 有哪些好的建站平台生意参谋官网
  • 莱州市做企业网站常用网站推广方法及资源
  • 做网站的介绍网站维护需要多长时间
  • 建始县城乡建设局网站子域名在线查询
  • 做网站业务员提成几个点google官网
  • github个人网站模板站内推广方案
  • 安徽宿州住房与城乡建设玩网站哈尔滨百度公司地址
  • 中国最大的免费素材网站淘宝关键词优化推广排名
  • 网站使用arial字体下载seo网站结构优化
  • b站直播免费吗营销案例网站
  • 深圳做网站排名公司网站优化排名优化
  • 网站建设中山优化海南seo代理加盟供应商
  • 网站开发 渠道整站优化网站
  • 重庆金融公司网站建设seo网站关键词优化价格
  • 石家庄关键词优化平台黑帽seo是什么意思
  • 字体设计类网站seo在中国
  • 网站域名的建立百色seo外包
  • wordpress admin menu重庆seo顾问服务
  • 企业网站定制多少钱sem代运营推广公司
  • java web网站开发框架病毒式营销
  • 男女做爰网站郑州搜狗关键词优化顾问
  • 保险预约关键词排名优化价格
  • 模板网站做外贸好不好俄罗斯搜索引擎入口
  • 杭州高端响应式网站阿里巴巴推广
  • 怎么做视频网站教程中国seo高手排行榜
  • 扬中网站建设多少钱百度seo搜索营销新视角
  • 淮北网站三合一建设哪里有正规的电商培训班
  • 什么做自己的网站营销案例分析
  • 嵌入式开发培训机构排名资源网站优化排名软件公司