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

电话推销网站建设门户网站建设工作

电话推销网站建设,门户网站建设工作,做一个免费网站的流程,哪个公司网站做的最好1.技术背景,想知道 redis 设置了TTL时间的key 过期,且有后续的业务处理的场景可以使用。 bug点: 使用redis 缓存失效监听会有一定的延迟, 过期事件是在redis服务器删除键的时候生成的,而不是在理论上生存时间到达0值得…

1.技术背景,想知道 redis 设置了TTL时间的key 过期,且有后续的业务处理的场景可以使用。
bug点:
使用redis 缓存失效监听会有一定的延迟, 过期事件是在redis服务器删除键的时候生成的,而不是在理论上生存时间到达0值得时候生成的。

搭建:
1.前置条件为 redis服务器端开启了事件通知。配置文件redis.conf文件中 开启相关配置。
默认情况下redis是未开启事件通知的。

############################# EVENT NOTIFICATION ############################### Redis can notify Pub/Sub clients about events happening in the key space.
# This feature is documented at https://redis.io/topics/notifications
#
# For instance if keyspace events notification is enabled, and a client
# performs a DEL operation on key "foo" stored in the Database 0, two
# messages will be published via Pub/Sub:
#
# PUBLISH __keyspace@0__:foo del
# PUBLISH __keyevent@0__:del foo
#
# It is possible to select the events that Redis will notify among a set
# of classes. Every class is identified by a single character:
#
#  K     Keyspace events, published with __keyspace@<db>__ prefix.
#  E     Keyevent events, published with __keyevent@<db>__ prefix.
#  g     Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ...
#  $     String commands
#  l     List commands
#  s     Set commands
#  h     Hash commands
#  z     Sorted set commands
#  x     Expired events (events generated every time a key expires)
#  e     Evicted events (events generated when a key is evicted for maxmemory)
#  t     Stream commands
#  d     Module key type events
#  m     Key-miss events (Note: It is not included in the 'A' class)
#  A     Alias for g$lshzxetd, so that the "AKE" string means all the events
#        (Except key-miss events which are excluded from 'A' due to their
#         unique nature).
#
#  The "notify-keyspace-events" takes as argument a string that is composed
#  of zero or multiple characters. The empty string means that notifications
#  are disabled.
#
#  By default all notifications are disabled because most users don't need
#  this feature and the feature has some overhead. Note that if you don't
#  specify at least one of K or E, no events will be delivered.
#  notify-keyspace-events ""
# 配置文件修改项
notify-keyspace-events "Ex" 

可直接修改 notify-keyspace-events “Ex” 即为开启了rediss 事件监听,然后重启redis 服务(或者使用命令的形式,不需要重启redis服务)。不同key 类型的监听见上文档。

2.项目中编写相关的监听程序(前置条件,redis已经集成进项目里了)

import com.jinyi.up.user.listener.RedisKeyExpirationListener;
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.KeyExpirationEventMessageListener;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
/*** spring容器 里通过 java配置方式注入RedisMessageListenerContainer 和  KeyExpirationEventMessageListener的实现类* @author jinyi* @date 2023/11/25 16:39* @desc*/
@Configuration
public class RedisListenerConfig {@BeanRedisMessageListenerContainer listenerContainer(RedisConnectionFactory connectionFactory) {RedisMessageListenerContainer listenerContainer = new RedisMessageListenerContainer();listenerContainer.setConnectionFactory(connectionFactory);return listenerContainer;}@BeanKeyExpirationEventMessageListener redisKeyExpirationListener(RedisMessageListenerContainer listenerContainer) {return new RedisKeyExpirationListener(listenerContainer);}}
import lombok.extern.slf4j.Slf4j;
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;/*** 使用redis 缓存失效监听会有一定的延迟, 过期事件是在redis服务器删除键的时候生成的,而不是在理论上生存时间到达0值得时候生成的,** @author jinyi* @date 2023/11/25 16:40* @desc*/
@Slf4j
@Component
public class RedisKeyExpirationListener extends KeyExpirationEventMessageListener {public RedisKeyExpirationListener(RedisMessageListenerContainer listenerContainer) {super(listenerContainer);}/*** 针对redis数据失效事件,进行数据处理** @param message key的信息,并不包含缓存值。* @param pattern*/@Overridepublic void onMessage(Message message, byte[] pattern) {//获得失效的keylog.info("KeyExpiration key:" + message);//todo 后续的业务处理}}
http://www.15wanjia.com/news/187739.html

相关文章:

  • 加强网站技术建设网站开发用什么技术做好
  • asp.net 微网站开发重庆模板网站哪个好
  • 电子商务网站建设与管理的学后感南昌做网站kaiu
  • 乌兰察布做网站的公司网站免费源码大全无用下载
  • 钢笔工具网站南通网站建设
  • 网站的原型怎么做电商网站前端源码
  • 网站备案制度有没有专做于投融资的网站
  • 公司网站怎么做中国华电集团电子商务平台
  • seo查询外链兰州优化网站
  • 贩卖做网站资料网站建设qianhaiyou
  • 毕业设计做网站题目烟台开发区网站
  • 婚恋网站A00网站建设
  • 有没有做书签的网站免费网站软件下载
  • 建设网站怎么提需求北京市住房及城乡建设部网站
  • 关键词抓取工具都有哪些东莞网站推广优化搜索推广
  • 网站备案资料手机购物网站模版
  • 网站项目合同门户网站html模板下载
  • 做图书馆网站模板ps课程教学零基础网课
  • 音乐网站怎么做外链wordpress团购主题
  • 如何做增加网站留存的营销活动深圳专业建设网站服务
  • 张家口住房和城乡建设厅网站深圳科技有限公司 网站建设
  • 西宁企业网站建设网上服装定制网站
  • 做外贸商城网站电商在线设计网站
  • 广西壮族自治区住房和城乡建设厅网站高埗网站建设公司
  • 新乡免费网站建设灯光照明网站建设
  • 四川建设网网网站维护电话快普网站怎么做采购退货
  • 河南省城乡与住房建设厅网站一二三四在线观看视频韩国
  • 免费关键词优化排名软件上海网站设计知名乐云seo
  • 个体户 建设网站微信小程序设计
  • 网址导航类网站怎么做ui是什么设计