0

At first, I use 'FindByIndexNameSessionRepository' and my webserver skill is like beginner.

I want to delete all spring session in redis or delete by lastAccessedTime. FindByIndexNameSessionRepository has deleteById but not deleteAll.

Why I find this, Redis session's index data are piled too many, these makes findByPrincipalName show slow performance.

Our project's session data control follow these steps.

  1. If user login to server, remove previous session data.
  2. create new session data.

In this steps, if many user login just once, unnecessary session data is piled up.

So I think, management index is delete data with some condition periodically.

If you know better idea or usual way to contol session, please guide to me.

Thanks.

Sizzling
  • 215
  • 1
  • 3
  • 7

1 Answers1

0

Ideally you should simply have an expiry so that removal of earlier sessions is handled by redis/spring itself. See: What is the default session timeout and how to configure it when using the Spring Session with Redis as the backend

As for existing buildup of older sessions after the above is implemented, you might be better off doing a one-time activity of iterating over all the sessions and deleting them (see https://redis.io/commands/scan)

hoodakaushal
  • 1,253
  • 2
  • 16
  • 31