Skip to content

perf(StringRedisTemplate): avoid redundant logger creation in execute(). #3173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 3.5.x
Choose a base branch
from

Conversation

huangcanda
Copy link

Problem Description

Each invocation of StringRedisTemplate.execute() creates a new DefaultStringRedisConnection instance, resulting in repeated initialization of non-static logger instances. This causes redundant LogFactory lookups that ​consume an additional 10–15% CPU overhead.

Solution

Modify the private final Log logger field in DefaultStringRedisConnection to private static final Log logger.

Impact

10–15% reduction in CPU overhead for all Redis client command executions.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 22, 2025
Static logger eliminates expensive initialization per invocation.

Signed-off-by: huangcanda <954060834@qq.com>
@huangcanda huangcanda force-pushed the fix/string-redis-template-connection-perf branch from dcd43b7 to 41d4bda Compare June 22, 2025 07:37
@mp911de mp911de added type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task A general task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants