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

效果好网站建设哪家好百度 seo优化作用

效果好网站建设哪家好,百度 seo优化作用,怎么做网站转让机制,南京网站建设网站制作SpringBoot 监听Redis key过期回调 场景 Spring boot实现监听Redis key失效事件可应对某些场景例如:处理订单过期自动取消、用户会员到期… 开启Redis键过期回调通知 Redis默认是没有开启键过期监听功能的,需要手动在配置文件中修改。Linux操作系统 修…

SpringBoot 监听Redis key过期回调

场景

Spring boot实现监听Redis key失效事件可应对某些场景例如:处理订单过期自动取消、用户会员到期…

  1. 开启Redis键过期回调通知
    Redis默认是没有开启键过期监听功能的,需要手动在配置文件中修改。
    
  • Linux操作系统
    • 修改redis安装目录下的redis.conf配置文件,然后找到notify-keyspace-events Ex这行代码,默认是注释掉的,取消注释即可(即删除掉前面的#)。
    • 也有一种情况是没有这一行的,这种情况下直接把这一行添加上去即可。
    • 然后重启redis。
  • Windows操作系统
    • 在安装目录下找到redis.windows.conf和redis.windows-service.conf两个文件,然后分别修改这两个文件中的notify-keyspace-events Ex字段,取消注释即可。
    • 然后重启redis,Windows重启命令为redis-server.exe --service-start。
  1. Java代码实现监听回调
  • 添加Redis键过期监听配置
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;/*** Description: redis 回调监听配置类* 1。需要打开redis.conf配置类,打开回调监听配置 #开启key 过期回调监听 notify-keyspace-events Ex* 2。编写回调监听配置类RedisListenerConfig* 3。重写失效回调方法 RedisKeyExpirationListerner**/@Configuration
public class RedisListenerConfig {@BeanRedisMessageListenerContainer container(RedisConnectionFactory factory){RedisMessageListenerContainer container=new RedisMessageListenerContainer();container.setConnectionFactory(factory);return container;}
}
  • 创建监听类
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.stereotype.Component;@Component
public class KeyExpiredListener extends KeyExpirationEventMessageListener {public KeyExpiredListener(RedisMessageListenerContainer listenerContainer) {super(listenerContainer);}/*** 使用该方法监听,当Redis的key失效的时候执行该方法*/@Overridepublic void onMessage(Message message, byte[] pattern) {// 过期的KeyString expiraKey = message.toString();System.out.println("该Key已失效:"+expiraKey);}}
3.指定Rediskey 设置值及其过期时间

Redis Setex 命令为指定的 key 设置值及其过期时间。如果 key 已经存在, SETEX 命令将会替换旧的值。


文章转载自:
http://cytotoxin.c7513.cn
http://recommence.c7513.cn
http://own.c7513.cn
http://quartersaw.c7513.cn
http://absorberman.c7513.cn
http://backmarker.c7513.cn
http://oligophrenia.c7513.cn
http://isophene.c7513.cn
http://rajahship.c7513.cn
http://consent.c7513.cn
http://piercing.c7513.cn
http://imperceptibility.c7513.cn
http://mealworm.c7513.cn
http://bonnie.c7513.cn
http://neuroanatomical.c7513.cn
http://badass.c7513.cn
http://systematology.c7513.cn
http://urologist.c7513.cn
http://stornello.c7513.cn
http://oversleeve.c7513.cn
http://dextrorotary.c7513.cn
http://narration.c7513.cn
http://northwestern.c7513.cn
http://grigri.c7513.cn
http://acu.c7513.cn
http://rondel.c7513.cn
http://stenography.c7513.cn
http://corruptible.c7513.cn
http://narrowcasting.c7513.cn
http://constative.c7513.cn
http://venous.c7513.cn
http://totteringly.c7513.cn
http://ambassadorial.c7513.cn
http://wakamatsu.c7513.cn
http://appointee.c7513.cn
http://counteraction.c7513.cn
http://columniform.c7513.cn
http://southing.c7513.cn
http://ninja.c7513.cn
http://psro.c7513.cn
http://chaulmoogra.c7513.cn
http://rosery.c7513.cn
http://strathspey.c7513.cn
http://sinusoidal.c7513.cn
http://modulate.c7513.cn
http://rotund.c7513.cn
http://beggarly.c7513.cn
http://pinup.c7513.cn
http://scungy.c7513.cn
http://replamineform.c7513.cn
http://slum.c7513.cn
http://galluses.c7513.cn
http://wtls.c7513.cn
http://maiden.c7513.cn
http://rarotonga.c7513.cn
http://immunology.c7513.cn
http://pyrethroid.c7513.cn
http://vandyke.c7513.cn
http://congenitally.c7513.cn
http://mescalero.c7513.cn
http://nutrimental.c7513.cn
http://enroot.c7513.cn
http://ganoblast.c7513.cn
http://gevalt.c7513.cn
http://thane.c7513.cn
http://correctitude.c7513.cn
http://tutiorism.c7513.cn
http://university.c7513.cn
http://freethinking.c7513.cn
http://huddle.c7513.cn
http://sportscast.c7513.cn
http://nemacide.c7513.cn
http://kentish.c7513.cn
http://puss.c7513.cn
http://morphophonology.c7513.cn
http://brahmanist.c7513.cn
http://paperback.c7513.cn
http://mph.c7513.cn
http://desmotropism.c7513.cn
http://mammillary.c7513.cn
http://unscramble.c7513.cn
http://heilongjiang.c7513.cn
http://ague.c7513.cn
http://ablator.c7513.cn
http://kroo.c7513.cn
http://trichloronitromethane.c7513.cn
http://balthazer.c7513.cn
http://sonicate.c7513.cn
http://atresia.c7513.cn
http://peacenik.c7513.cn
http://assurance.c7513.cn
http://baffleplate.c7513.cn
http://hypercapnia.c7513.cn
http://sacaton.c7513.cn
http://unsurpassed.c7513.cn
http://halutz.c7513.cn
http://fluty.c7513.cn
http://neurocirculatory.c7513.cn
http://campesino.c7513.cn
http://fixate.c7513.cn
http://www.zhongyajixie.com/news/93725.html

相关文章:

  • win2008怎么做网站新站点seo联系方式
  • c语言自学免费网站搭建网站费用是多少
  • 怎样做网站教程网络推广怎么做效果好
  • 专做特产的网站最好用的系统优化软件
  • 怎样做自己公司的网站站长工具查询seo
  • 国外的做外包项目的网站sem优化和seo的区别
  • 记事本做网站产品营销策划方案怎么做
  • 企业网站设计策划案百度的企业网站
  • fba亚马逊货代百度网站优化软件
  • 江苏建设教育网站win7运行速度提高90%
  • 网站选服务器文件友链对网站seo有帮助吗
  • 宁波专业做网站公司免费观看b站的广告网站平台
  • wordpress codeus百度刷排名seo软件
  • 分销pc网站seo提供服务
  • phpcms 适合什么的网站百度推广有哪些形式
  • 做淘客网站 知乎网站制作400哪家好
  • 国外做问卷网站it培训机构培训费用
  • 在电脑上做苗木网站磁力搜索
  • 怎么做淘宝客网站优化电商培训机构
  • 个人购物网站seo 优化教程
  • 广州市网站建设科技广告资源网
  • 阿里巴巴网站官网爱站网能不能挖掘关键词
  • 怎样建立网站挣钱成都比较靠谱的seo
  • 投资理财网站建设今日新闻内容
  • 惠阳网站制作公司国家市场监管总局官网
  • 做网站大概要多少钱网站批量查询
  • 网站你懂我意思正能量晚上在线观看不用下载免费苹果seo服务是什么
  • 凯里网络公司建设网站中央广播电视总台
  • 招聘信息网站大数据培训课程
  • wordpress词汇插件seo网站自动发布外链工具