【原创】大叔问题定位分享(35)spring中session失效时间
spring项目中将sessionid对应的cookie过期时间设置很长,但是实际session还是在半个小时后失效,跟了一下代码,spring中session实现接口为
org.springframework.session.SessionRepository
public interface SessionRepository<S extends Session> {
S createSession();
void save(S var1);
S findById(String var1);
void deleteById(String var1);
}
这个接口有两个实现类:
MapSessionRepository
RedisOperationsSessionRepository
单机环境使用前者,分布式环境使用后者,来看后者代码:
org.springframework.session.data.redis.RedisOperationsSessionRepository
public RedisOperationsSessionRepository.RedisSession createSession() {
RedisOperationsSessionRepository.RedisSession redisSession = new RedisOperationsSessionRepository.RedisSession();
if(this.defaultMaxInactiveInterval != null) {
redisSession.setMaxInactiveInterval(Duration.ofSeconds((long)this.defaultMaxInactiveInterval.intValue()));
}
return redisSession;
}
org.springframework.session.data.redis.RedisOperationsSessionRepository.RedisSession
RedisSession() {
this(new MapSession());
this.delta.put("creationTime", Long.valueOf(this.getCreationTime().toEpochMilli()));
this.delta.put("maxInactiveInterval", Integer.valueOf((int)this.getMaxInactiveInterval().getSeconds()));
this.delta.put("lastAccessedTime", Long.valueOf(this.getLastAccessedTime().toEpochMilli()));
this.isNew = true;
this.flushImmediateIfNecessary();
}
public boolean isExpired() {
return this.cached.isExpired();
}
org.springframework.session.MapSession
public boolean isExpired() {
return this.isExpired(Instant.now());
}
boolean isExpired(Instant now) {
return this.maxInactiveInterval.isNegative()?false:now.minus(this.maxInactiveInterval).compareTo(this.lastAccessedTime) >= 0;
}
可见是在创建session的时候设置两个时间,
lastAccessedTime
maxInactiveInterval
如果 当前时间 - maxInactiveInterval > lastAccessedTime 就会认为session过期,设置的方法:
@EnableRedisHttpSession(maxInactiveIntervalInSeconds=2000)
【原创】大叔问题定位分享(35)spring中session失效时间的更多相关文章
- 关于Flask-Login中session失效时间的处理
最近需要使用Python开发web系统,主要用到的框架就是Flask,前端使用Jinja2模板引擎和Bootstrap,web容器使用Cherrypy,其中关于Login管理的使用了Flask-Log ...
- 【原创】大叔问题定位分享(27)spark中rdd.cache
spark 2.1.1 spark应用中有一些task非常慢,持续10个小时,有一个task日志如下: 2019-01-24 21:38:56,024 [dispatcher-event-loop-2 ...
- 【原创】大叔问题定位分享(11)Spark中对大表子查询加limit为什么会报Broadcast超时错误
当两个表需要join时,如果一个是大表,一个是小表,正常的map-reduce流程需要shuffle,这会导致大表数据在节点间网络传输,常见的优化方式是将小表读到内存中并广播到大表处理,避免shuff ...
- 【原创】大叔问题定位分享(7)Spark任务中Job进度卡住不动
Spark2.1.1 最近运行spark任务时会发现任务经常运行很久,具体job如下: Job Id ▾ Description Submitted Duration Stages: Succeed ...
- 【原创】大叔问题定位分享(36)openresty(nginx+lua)中获取不到post数据,ngx.req.get_body_data返回nil
openresty(nginx+lua)中获取不到post数据,ngx.req.get_body_data返回nil This function returns nil if the request ...
- 【原创】大叔问题定位分享(34)Spring的RestTemplate请求json数据后内容被修改
先看代码 org.springframework.web.client.RestTemplate public RestTemplate() { this.messageConverters = ne ...
- 【原创】大叔问题定位分享(3)Kafka集群broker进程逐个报错退出
kafka0.8.1 一 问题现象 生产环境kafka服务器134.135.136分别在10月11号.10月13号挂掉: 134日志 [2014-10-13 16:45:41,902] FATAL [ ...
- 【原创】大叔问题定位分享(28)openssh升级到7.4之后ssh跳转异常
服务器集群之间忽然ssh跳转不通 # ssh 192.168.0.1The authenticity of host '192.168.0.1 (192.168.0.1)' can't be esta ...
- 【原创】大叔问题定位分享(6)Dubbo monitor服务iowait高,负载高
一 问题 Dubbo monitor所在服务器状态异常,iowait一直很高,load也一直很高,监控如下: iowait如图: load如图: 二 分析 通过iotop命令可以查看当前系统中磁盘io ...
随机推荐
- 【SR汇总】基于深度学习方法
1.SRCNN.FSRCNN (Learning a Deep Convolutional Network for Image Super-Resolution, ECCV2014) (Acceler ...
- leetcode1284 转化为全零矩阵的最少反转次数
m == mat.length n == mat[0].length 1 <= m <= 3 1 <= n <= 3 mat[i][j] 是 0 或 1 . BFS, 代码来自 ...
- LC 241. Different Ways to Add Parentheses
Given a string of numbers and operators, return all possible results from computing all the differen ...
- flutter 常用plugins
搜索plugins flutter plugins搜索地址 谷歌官方plugins https://pub.dev/packages?q=http 到这个链接里面去搜索 https://github. ...
- Rancher Server部署方式及Rancher HA环境部署
类似Rancher这种的容器管理和编排工具,它可以很快地让每个组织获得高效的弹性集群管理能力.当前技术世界的发展形势就是让开发人员从繁琐的应用配置和管理中解放出来,使用容器镜像来处理复杂的程序运行依赖 ...
- 分布式存储ceph--添加/删除osd(5)
一.添加osd: 当前ceph集群中有如下osd,现在准备新添加osd:
- VLAN和VXLAN的区别
VLAN ·概况 VLAN (Virtual Local Area Network)意为虚拟局域网,是在交换机实现过程中涉及到的概念,由802.1Q标准所定义.由于交换机是工作在链路层的网络设备,连接 ...
- Dubbo ==> 简介
一.架构发展过程 首先,我们先来看看上面的架构发展的线路图:单一应用架构 --> 垂直应用架构 --> 分布式服务架构 --> 流动计算架构 . 单一应用架构 在一些中小型的传统软件 ...
- python实现在目录中查找指定文件的方法
python实现在目录中查找指定文件的方法 本文实例讲述了python实现在目录中查找指定文件的方法.分享给大家供大家参考.具体实现方法如下: 1. 模糊查找 代码如下: import os from ...
- ToolBar跟随键盘弹出和隐藏
实现效果如下: 代码实现如下: // // ViewController.m // PopToolBarDemo // // Created by 思 彭 on 2017/7/20. // Copyr ...