Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
55141926
Commit
55141926
authored
May 09, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.1.x'
Closes gh-16809
parents
bf294a76
75f48964
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
7 deletions
+38
-7
JedisConnectionConfiguration.java
...utoconfigure/data/redis/JedisConnectionConfiguration.java
+4
-0
LettuceConnectionConfiguration.java
...oconfigure/data/redis/LettuceConnectionConfiguration.java
+4
-0
RedisProperties.java
...mework/boot/autoconfigure/data/redis/RedisProperties.java
+17
-2
RedisAutoConfigurationJedisTests.java
...onfigure/data/redis/RedisAutoConfigurationJedisTests.java
+10
-5
RedisAutoConfigurationTests.java
...autoconfigure/data/redis/RedisAutoConfigurationTests.java
+3
-0
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/JedisConnectionConfiguration.java
View file @
55141926
...
...
@@ -113,6 +113,10 @@ class JedisConnectionConfiguration extends RedisConnectionConfiguration {
config
.
setMaxTotal
(
pool
.
getMaxActive
());
config
.
setMaxIdle
(
pool
.
getMaxIdle
());
config
.
setMinIdle
(
pool
.
getMinIdle
());
if
(
pool
.
getTimeBetweenEvictionRuns
()
!=
null
)
{
config
.
setTimeBetweenEvictionRunsMillis
(
pool
.
getTimeBetweenEvictionRuns
().
toMillis
());
}
if
(
pool
.
getMaxWait
()
!=
null
)
{
config
.
setMaxWaitMillis
(
pool
.
getMaxWait
().
toMillis
());
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.java
View file @
55141926
...
...
@@ -146,6 +146,10 @@ class LettuceConnectionConfiguration extends RedisConnectionConfiguration {
config
.
setMaxTotal
(
properties
.
getMaxActive
());
config
.
setMaxIdle
(
properties
.
getMaxIdle
());
config
.
setMinIdle
(
properties
.
getMinIdle
());
if
(
properties
.
getTimeBetweenEvictionRuns
()
!=
null
)
{
config
.
setTimeBetweenEvictionRunsMillis
(
properties
.
getTimeBetweenEvictionRuns
().
toMillis
());
}
if
(
properties
.
getMaxWait
()
!=
null
)
{
config
.
setMaxWaitMillis
(
properties
.
getMaxWait
().
toMillis
());
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisProperties.java
View file @
55141926
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -171,7 +171,8 @@ public class RedisProperties {
/**
* Target for the minimum number of idle connections to maintain in the pool. This
* setting only has an effect if it is positive.
* setting only has an effect if both it and time between eviction runs are
* positive.
*/
private
int
minIdle
=
0
;
...
...
@@ -188,6 +189,12 @@ public class RedisProperties {
*/
private
Duration
maxWait
=
Duration
.
ofMillis
(-
1
);
/**
* Time between runs of the idle object evictor thread. When positive, the idle
* object evictor thread starts, otherwise no idle object eviction is performed.
*/
private
Duration
timeBetweenEvictionRuns
;
public
int
getMaxIdle
()
{
return
this
.
maxIdle
;
}
...
...
@@ -220,6 +227,14 @@ public class RedisProperties {
this
.
maxWait
=
maxWait
;
}
public
Duration
getTimeBetweenEvictionRuns
()
{
return
this
.
timeBetweenEvictionRuns
;
}
public
void
setTimeBetweenEvictionRuns
(
Duration
timeBetweenEvictionRuns
)
{
this
.
timeBetweenEvictionRuns
=
timeBetweenEvictionRuns
;
}
}
/**
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java
View file @
55141926
...
...
@@ -134,11 +134,14 @@ public class RedisAutoConfigurationJedisTests {
@Test
public
void
testRedisConfigurationWithPool
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.redis.host:foo"
,
"spring.redis.jedis.pool.min-idle:1"
,
"spring.redis.jedis.pool.max-idle:4"
,
"spring.redis.jedis.pool.max-active:16"
,
"spring.redis.jedis.pool.max-wait:2000"
).
run
((
context
)
->
{
this
.
contextRunner
.
withPropertyValues
(
"spring.redis.host:foo"
,
"spring.redis.jedis.pool.min-idle:1"
,
"spring.redis.jedis.pool.max-idle:4"
,
"spring.redis.jedis.pool.max-active:16"
,
"spring.redis.jedis.pool.max-wait:2000"
,
"spring.redis.jedis.pool.time-between-eviction-runs:30000"
)
.
run
((
context
)
->
{
JedisConnectionFactory
cf
=
context
.
getBean
(
JedisConnectionFactory
.
class
);
assertThat
(
cf
.
getHostName
()).
isEqualTo
(
"foo"
);
...
...
@@ -146,6 +149,8 @@ public class RedisAutoConfigurationJedisTests {
assertThat
(
cf
.
getPoolConfig
().
getMaxIdle
()).
isEqualTo
(
4
);
assertThat
(
cf
.
getPoolConfig
().
getMaxTotal
()).
isEqualTo
(
16
);
assertThat
(
cf
.
getPoolConfig
().
getMaxWaitMillis
()).
isEqualTo
(
2000
);
assertThat
(
cf
.
getPoolConfig
().
getTimeBetweenEvictionRunsMillis
())
.
isEqualTo
(
30000
);
});
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationTests.java
View file @
55141926
...
...
@@ -155,6 +155,7 @@ public class RedisAutoConfigurationTests {
"spring.redis.lettuce.pool.max-idle:4"
,
"spring.redis.lettuce.pool.max-active:16"
,
"spring.redis.lettuce.pool.max-wait:2000"
,
"spring.redis.lettuce.pool.time-between-eviction-runs:30000"
,
"spring.redis.lettuce.shutdown-timeout:1000"
).
run
((
context
)
->
{
LettuceConnectionFactory
cf
=
context
.
getBean
(
LettuceConnectionFactory
.
class
);
...
...
@@ -165,6 +166,8 @@ public class RedisAutoConfigurationTests {
assertThat
(
poolConfig
.
getMaxIdle
()).
isEqualTo
(
4
);
assertThat
(
poolConfig
.
getMaxTotal
()).
isEqualTo
(
16
);
assertThat
(
poolConfig
.
getMaxWaitMillis
()).
isEqualTo
(
2000
);
assertThat
(
poolConfig
.
getTimeBetweenEvictionRunsMillis
())
.
isEqualTo
(
30000
);
assertThat
(
cf
.
getShutdownTimeout
()).
isEqualTo
(
1000
);
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment