Spring Session中存放于Redis中的PRINCIPAL_NAME_INDEX_NAME没有设置过期时间

背景

Spring Session中我使用的是Spring Session Redis Data,默认采用FindByIndexNameSessionRepository作为SessionRepository实现。

但是我在Redis中发现,前缀为spring:session:index:org.springframework.session.FindByIndexNameSessionRepository的键。PRINCIPAL_NAME_INDEX_NAME:TTL为-1,也就是永不过期,到时Redis中存在大量的这样的数据键。

为什么存储客户登录态,按理说在用户退出登录或者session到期之后要怎么删除,但是为什么TTL一致都是-1呢。

答案

https://stackoverflow.com/questions/70891524/spring-session-redis-data-is-not-clearing-index-to-sessions-in-redis

这是一个Spring Session官方BUG,This is a bug in Spring Session version 2.5.3 and prior.If you update to Spring Session 2.5.4 or any 2.6.x, the issue is fixed.

ISSUE LINKS : https://github.com/spring-projects/spring-session/issues/1791

ISSUE CODE : https://github.com/spring-projects/spring-session/pull/1941/commits/e7f64a2d3ebc7060e56476de18f6fe56a1bb9a59

解决

升级Spring Session到2.5.4或者任意2.6.x版本, 这个问题就会被修复。

 

本篇文章如有帮助到您,请给「翎野君」点个赞,感谢您的支持。

首发链接:https://www.cnblogs.com/lingyejun/p/16886380.html

posted @ 2022-11-13 17:25  翎野君  阅读(745)  评论(0编辑  收藏  举报