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 2 commits into
base: 3.5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
public abstract class AbstractRedisConnection implements RedisConnection {

private final Log LOGGER = LogFactory.getLog(getClass());
private static final Log LOGGER = LogFactory.getLog(AbstractRedisConnection.class);

private @Nullable RedisSentinelConfiguration sentinelConfiguration;
private final Map<RedisNode, RedisSentinelConnection> connectionCache = new ConcurrentHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco

private static final byte[][] EMPTY_2D_BYTE_ARRAY = new byte[0][];

private final Log log = LogFactory.getLog(DefaultStringRedisConnection.class);
private static final Log log = LogFactory.getLog(DefaultStringRedisConnection.class);
private final RedisConnection delegate;
private final RedisSerializer<String> serializer;
private Converter<byte[], String> bytesToString = new DeserializingConverter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class JedisClusterConnection implements RedisClusterConnection {
private static final ExceptionTranslationStrategy EXCEPTION_TRANSLATION = new FallbackExceptionTranslationStrategy(
JedisExceptionConverter.INSTANCE);

private final Log log = LogFactory.getLog(getClass());
private static final Log log = LogFactory.getLog(JedisClusterConnection.class);

private final JedisCluster cluster;
private final JedisClusterGeoCommands geoCommands = new JedisClusterGeoCommands(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
*/
public class JedisConnection extends AbstractRedisConnection {

private static final Log LOGGER = LogFactory.getLog(JedisConnection.class);

private static final ExceptionTranslationStrategy EXCEPTION_TRANSLATION =
new FallbackExceptionTranslationStrategy(JedisExceptionConverter.INSTANCE);

Expand Down Expand Up @@ -108,8 +110,6 @@ public class JedisConnection extends AbstractRedisConnection {
private final JedisStringCommands stringCommands = new JedisStringCommands(this);
private final JedisZSetCommands zSetCommands = new JedisZSetCommands(this);

private final Log LOGGER = LogFactory.getLog(getClass());

@SuppressWarnings("rawtypes")
private List<JedisResult> pipelinedResults = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
public class LettuceClusterConnection extends LettuceConnection
implements RedisClusterConnection, DefaultedRedisClusterConnection {

private static final Log log = LogFactory.getLog(LettuceClusterConnection.class);

static final ExceptionTranslationStrategy exceptionConverter = new PassThroughExceptionTranslationStrategy(
LettuceExceptionConverter.INSTANCE);

Expand All @@ -79,8 +81,6 @@ public class LettuceClusterConnection extends LettuceConnection

private ClusterTopologyProvider topologyProvider;

private final Log log = LogFactory.getLog(getClass());

private final LettuceClusterGeoCommands geoCommands = new LettuceClusterGeoCommands(this);
private final LettuceClusterHashCommands hashCommands = new LettuceClusterHashCommands(this);
private final LettuceClusterHyperLogLogCommands hllCommands = new LettuceClusterHyperLogLogCommands(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@
*/
public class LettuceConnection extends AbstractRedisConnection {

private static final Log LOGGER = LogFactory.getLog(LettuceConnection.class);

private static final ExceptionTranslationStrategy EXCEPTION_TRANSLATION = new FallbackExceptionTranslationStrategy(
LettuceExceptionConverter.INSTANCE);

Expand Down Expand Up @@ -154,8 +156,6 @@ public List<Object> convert(List<Object> execResults) {

private @Nullable List<LettuceResult<?, ?>> ppline;

private final Log LOGGER = LogFactory.getLog(getClass());

private PipeliningFlushPolicy pipeliningFlushPolicy = PipeliningFlushPolicy.flushEachCommand();

private @Nullable PipeliningFlushState pipeliningFlushState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
public class LettuceConnectionFactory implements RedisConnectionFactory, ReactiveRedisConnectionFactory,
InitializingBean, DisposableBean, SmartLifecycle {

private static final Log log = LogFactory.getLog(LettuceConnectionFactory.class);

private static final ExceptionTranslationStrategy EXCEPTION_TRANSLATION = new PassThroughExceptionTranslationStrategy(
LettuceExceptionConverter.INSTANCE);

Expand All @@ -144,8 +146,6 @@ public class LettuceConnectionFactory implements RedisConnectionFactory, Reactiv
private @Nullable LettuceConnectionProvider connectionProvider;
private @Nullable LettuceConnectionProvider reactiveConnectionProvider;

private final Log log = LogFactory.getLog(getClass());

private final Lock lock = new ReentrantLock();

private PipeliningFlushPolicy pipeliningFlushPolicy = PipeliningFlushPolicy.flushEachCommand();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public class RedisKeyValueAdapter extends AbstractKeyValueAdapter
*/
private static final int PHANTOM_KEY_TTL = 300;

private final Log logger = LogFactory.getLog(getClass());
private static final Log logger = LogFactory.getLog(RedisKeyValueAdapter.class);
private final AtomicReference<State> state = new AtomicReference<>(State.CREATED);

private RedisOperations<?, ?> redisOps;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@
*/
public class RedisMessageListenerContainer implements InitializingBean, DisposableBean, BeanNameAware, SmartLifecycle {

protected static final Log logger = LogFactory.getLog(RedisMessageListenerContainer.class);

/**
* The default recovery interval: 5000 ms = 5 seconds.
*/
Expand All @@ -123,9 +125,6 @@ public class RedisMessageListenerContainer implements InitializingBean, Disposab
public static final String DEFAULT_THREAD_NAME_PREFIX = ClassUtils.getShortName(RedisMessageListenerContainer.class)
+ "-";

/** Logger available to subclasses */
protected final Log logger = LogFactory.getLog(getClass());

// whether the container has been initialized via afterPropertiesSet
private boolean afterPropertiesSet = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ public String getMethodName() {
*/
public static final String ORIGINAL_DEFAULT_LISTENER_METHOD = "handleMessage";

/** Logger available to subclasses */
protected final Log logger = LogFactory.getLog(getClass());
protected static final Log logger = LogFactory.getLog(MessageListenerAdapter.class);

private volatile @Nullable Object delegate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
*/
public class RedisRepositoryExtension extends CdiRepositoryExtensionSupport {

private final Log log = LogFactory.getLog(RedisRepositoryExtension.class);
private static final Log log = LogFactory.getLog(RedisRepositoryExtension.class);
private final Map<Set<Annotation>, Bean<RedisKeyValueAdapter>> redisKeyValueAdapters = new HashMap<>();
private final Map<Set<Annotation>, Bean<KeyValueOperations>> redisKeyValueTemplates = new HashMap<>();
private final Map<Set<Annotation>, Bean<RedisOperations<?, ?>>> redisOperations = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
*/
class DefaultStreamReceiver<K, V extends Record<K, ?>> implements StreamReceiver<K, V> {

private final Log logger = LogFactory.getLog(getClass());
private static final Log logger = LogFactory.getLog(DefaultStreamReceiver.class);
private final ReactiveRedisTemplate<K, ?> template;
private final ReactiveStreamOperations<K, Object, Object> streamOperations;
private final StreamReadOptions readOptions;
Expand Down