skip to Main Content

I am new to spring-data-redis. I have integrated with a spring-boot application. As part of this, I have added a few configs as follows:

spring.session.store-type=redis
spring.session.redis.namespace=tc
server.servlet.session.timeout=5h

But even after having the expiry timeout as 5 hrs, I see all records which are months old, in redis:

127.0.0.1:6379> keys *
  1) "tc:expirations:1653887100000"
  2) "tc:sessions:2a4d193c-612b-48b6-8b7a-3ac525aba2d4"
  3) "tc:sessions:fd10e891-357a-4cd4-a14b-58a1bb2e16ae"
  4) "tc:sessions:expires:99969082-b0bc-4122-9511-1aba098a0eb7"
  5) "tc:sessions:expires:b9a84856-9971-4e9e-bfec-9037ceb7d317"
  6) "tc:expirations:1653897300000"
  7) "tc:sessions:expires:b8c9969c-6bde-4aca-8d2e-7510d90f9706"
  8) "tc:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:abcd"

In this context, I have gone through: Spring Session with Redis – server.session.timeout has no effect and I see I have done exactly the same as the accepted answer suggested. So I am not sure, what I am missing here.

2

Answers


  1. Here’s a configuration i’ve done on my project with Spring session and Redis
    The timeout should be set on spring session parameters

    *Sorry for the yaml… 🙂 *

    spring:
      redis:
        host: localhost
        port: 6379
      session:
        store-type: redis
        timeout: 3000
        redis:
          namespace: spring:session
          flush-mode: on_save
    
    Login or Signup to reply.
  2. If you are using the @EnableRedisHttpSession annotation you need to set maxInactiveIntervalInSeconds like:

    @EnableRedisHttpSession(maxInactiveIntervalInSeconds = 86400)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search