spring-projects / spring-projects/spring-session

Add Configurable Property for Custom Session Index Name in Redis

Open
#3,254 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage type: enhancement
Dominant language
Java
Stars
1.9k
Forks
1.2k
Avg merge
4h 27m
Merged PRs (30d)
55

Description

Note: I'm not sure if it's currently possible to configure this index name, at least not in an easy or straightforward way.

It should be possible to configure a custom name for the session index, allowing shorter and more readable entries in Redis. This could help users who need simpler key structures for session management, enhancing readability and potentially optimizing performance by avoiding long, repetitive index names.

Currently, the session index name is hard-coded asorg.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME. When retrieving keys with commands like keys *, this long, detailed naming convention leads to outputs such as:

spring:session:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:pedro123

This default naming makes the keys verbose and harder to work with.

This issue impacts readability and manageability of session-related keys in Redis. When working with numerous sessions, especially for applications with a high volume of users, this long index name can clutter the database and make debugging more challenging. I've explored options for a workaround, but currently, the only solution would be to allow a configurable property for this session index name.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the hard-coded PRINCIPAL_NAME_INDEX_NAME usage in the Redis session implementation and its configuration entry points. Confirm how the current key is assembled and define done as allowing a custom index name while retaining the existing default behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, redis
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.