Make sure Redis cache prefix includes cache name
This commit maps 'spring.cache.redis.key-prefix' to the new 'prefixCacheNameWith' method introduced in Spring Data Neumann. This makes sure that the configured prefix includes the cache name. Closes gh-16676
This commit is contained in:
parent
3fe4245ab6
commit
7f6b01c3d2
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
@ -85,7 +85,7 @@ class RedisCacheConfiguration {
|
|||
config = config.entryTtl(redisProperties.getTimeToLive());
|
||||
}
|
||||
if (redisProperties.getKeyPrefix() != null) {
|
||||
config = config.prefixKeysWith(redisProperties.getKeyPrefix());
|
||||
config = config.prefixCacheNameWith(redisProperties.getKeyPrefix());
|
||||
}
|
||||
if (!redisProperties.isCacheNullValues()) {
|
||||
config = config.disableCachingNullValues();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
@ -252,7 +252,7 @@ class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationTests {
|
|||
RedisCacheConfiguration redisCacheConfiguration = getDefaultRedisCacheConfiguration(cacheManager);
|
||||
assertThat(redisCacheConfiguration.getTtl()).isEqualTo(java.time.Duration.ofSeconds(15));
|
||||
assertThat(redisCacheConfiguration.getAllowCacheNullValues()).isFalse();
|
||||
assertThat(redisCacheConfiguration.getKeyPrefixFor("keyName")).isEqualTo("prefix");
|
||||
assertThat(redisCacheConfiguration.getKeyPrefixFor("MyCache")).isEqualTo("prefixMyCache::");
|
||||
assertThat(redisCacheConfiguration.usePrefix()).isTrue();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue