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
d22cd0cc
Commit
d22cd0cc
authored
Jul 12, 2017
by
Mark Paluch
Committed by
Stephane Nicoll
Jul 13, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Align with breaking API changes in RedisCacheManager
See gh-9734
parent
5416eac6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
13 deletions
+18
-13
RedisCacheConfiguration.java
...ork/boot/autoconfigure/cache/RedisCacheConfiguration.java
+11
-8
CacheAutoConfigurationTests.java
...boot/autoconfigure/cache/CacheAutoConfigurationTests.java
+7
-5
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/RedisCacheConfiguration.java
View file @
d22cd0cc
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
cache
;
package
org
.
springframework
.
boot
.
autoconfigure
.
cache
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.List
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
...
@@ -27,17 +28,19 @@ import org.springframework.context.annotation.Bean;
...
@@ -27,17 +28,19 @@ import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Conditional
;
import
org.springframework.context.annotation.Conditional
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.cache.RedisCacheManager
;
import
org.springframework.data.redis.cache.RedisCacheManager
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.cache.RedisCacheManager.RedisCacheManagerBuilder
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
/**
/**
* Redis cache configuration.
* Redis cache configuration.
*
*
* @author Stephane Nicoll
* @author Stephane Nicoll
* @author Mark Paluch
* @since 1.3.0
* @since 1.3.0
*/
*/
@Configuration
@Configuration
@AutoConfigureAfter
(
RedisAutoConfiguration
.
class
)
@AutoConfigureAfter
(
RedisAutoConfiguration
.
class
)
@ConditionalOnBean
(
Redis
Template
.
class
)
@ConditionalOnBean
(
Redis
ConnectionFactory
.
class
)
@ConditionalOnMissingBean
(
CacheManager
.
class
)
@ConditionalOnMissingBean
(
CacheManager
.
class
)
@Conditional
(
CacheCondition
.
class
)
@Conditional
(
CacheCondition
.
class
)
class
RedisCacheConfiguration
{
class
RedisCacheConfiguration
{
...
@@ -53,14 +56,14 @@ class RedisCacheConfiguration {
...
@@ -53,14 +56,14 @@ class RedisCacheConfiguration {
}
}
@Bean
@Bean
public
RedisCacheManager
cacheManager
(
Redis
Template
<
Object
,
Object
>
redisTemplate
)
{
public
RedisCacheManager
cacheManager
(
Redis
ConnectionFactory
redisConnectionFactory
)
{
RedisCacheManager
cacheManager
=
new
RedisCacheManager
(
redisTemplate
);
cacheManager
.
setUsePrefix
(
true
);
RedisCacheManagerBuilder
builder
=
RedisCacheManager
.
builder
(
redisConnectionFactory
);
List
<
String
>
cacheNames
=
this
.
cacheProperties
.
getCacheNames
();
List
<
String
>
cacheNames
=
this
.
cacheProperties
.
getCacheNames
();
if
(!
cacheNames
.
isEmpty
())
{
if
(!
cacheNames
.
isEmpty
())
{
cacheManager
.
setCacheNames
(
cacheNames
);
builder
.
initialCacheNames
(
new
LinkedHashSet
<>(
cacheNames
)
);
}
}
return
this
.
customizerInvoker
.
customize
(
cacheManager
);
return
this
.
customizerInvoker
.
customize
(
builder
.
build
()
);
}
}
}
}
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java
View file @
d22cd0cc
...
@@ -79,7 +79,7 @@ import org.springframework.context.annotation.Import;
...
@@ -79,7 +79,7 @@ import org.springframework.context.annotation.Import;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.data.redis.cache.RedisCacheManager
;
import
org.springframework.data.redis.cache.RedisCacheManager
;
import
org.springframework.data.redis.co
re.RedisTemplate
;
import
org.springframework.data.redis.co
nnection.RedisConnectionFactory
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
...
@@ -92,6 +92,7 @@ import static org.mockito.Mockito.verify;
...
@@ -92,6 +92,7 @@ import static org.mockito.Mockito.verify;
*
*
* @author Stephane Nicoll
* @author Stephane Nicoll
* @author Eddú Meléndez
* @author Eddú Meléndez
* @author Mark Paluch
*/
*/
@RunWith
(
ModifiedClassPathRunner
.
class
)
@RunWith
(
ModifiedClassPathRunner
.
class
)
@ClassPathExclusions
(
"hazelcast-client-*.jar"
)
@ClassPathExclusions
(
"hazelcast-client-*.jar"
)
...
@@ -282,8 +283,9 @@ public class CacheAutoConfigurationTests {
...
@@ -282,8 +283,9 @@ public class CacheAutoConfigurationTests {
RedisCacheManager
cacheManager
=
validateCacheManager
(
context
,
RedisCacheManager
cacheManager
=
validateCacheManager
(
context
,
RedisCacheManager
.
class
);
RedisCacheManager
.
class
);
assertThat
(
cacheManager
.
getCacheNames
()).
isEmpty
();
assertThat
(
cacheManager
.
getCacheNames
()).
isEmpty
();
assertThat
((
Boolean
)
new
DirectFieldAccessor
(
cacheManager
)
org
.
springframework
.
data
.
redis
.
cache
.
RedisCacheConfiguration
configuration
=
(
org
.
springframework
.
data
.
redis
.
cache
.
RedisCacheConfiguration
)
new
DirectFieldAccessor
(
.
getPropertyValue
(
"usePrefix"
)).
isTrue
();
cacheManager
).
getPropertyValue
(
"defaultCacheConfig"
);
assertThat
(
configuration
.
usePrefix
()).
isTrue
();
});
});
}
}
...
@@ -892,8 +894,8 @@ public class CacheAutoConfigurationTests {
...
@@ -892,8 +894,8 @@ public class CacheAutoConfigurationTests {
static
class
RedisCacheConfiguration
{
static
class
RedisCacheConfiguration
{
@Bean
@Bean
public
Redis
Template
<?,
?>
redisTemplate
()
{
public
Redis
ConnectionFactory
redisConnectionFactory
()
{
return
mock
(
Redis
Template
.
class
);
return
mock
(
Redis
ConnectionFactory
.
class
);
}
}
}
}
...
...
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