Skip to content

Commit 0fdea07

Browse files
tamilselvan-chinnaswamymp911de
authored andcommitted
DATAREDIS-1062 - Disable select dbIndex in case dbIndex is 0.
When shareNativeConnection was set to false and enabled connection pooling before executing each Redis command, select dbIndex command was executed. Selecting the database can be superfluous when the connection already uses the right database index. Original pull request: spring-projects#496.
1 parent 74cf627 commit 0fdea07

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,10 +975,13 @@ RedisClusterCommands<byte[], byte[]> getDedicatedConnection() {
975975
if (asyncDedicatedConn == null) {
976976

977977
asyncDedicatedConn = doGetAsyncDedicatedConnection();
978-
979-
if (asyncDedicatedConn instanceof StatefulRedisConnection) {
978+
979+
if (asyncDedicatedConn instanceof StatefulRedisConnection && dbIndex > 0) {
980980
((StatefulRedisConnection<byte[], byte[]>) asyncDedicatedConn).sync().select(dbIndex);
981981
}
982+
else if (asyncDedicatedConn instanceof StatefulRedisConnection) {
983+
((StatefulRedisConnection<byte[], byte[]>) asyncDedicatedConn).sync();
984+
}
982985
}
983986

984987
if (asyncDedicatedConn instanceof StatefulRedisConnection) {

0 commit comments

Comments
 (0)