DATAREDIS-767 - Add flag to disable in flight Cache creation.

We now provide a flag to disable the in flight cache creation for unconfigured caches. This gives eg. a CompositeCacheManager the possibility to chime in.

Original pull request: #311.
This commit is contained in:
Christoph Strobl
2018-02-15 10:17:08 +01:00
committed by Mark Paluch
parent 3f7f98e229
commit 8142836bbf
2 changed files with 105 additions and 13 deletions

View File

@@ -91,4 +91,23 @@ public class RedisCacheManagerUnitTests {
assertThat(cache).isInstanceOfAny(TransactionAwareCacheDecorator.class);
assertThat(ReflectionTestUtils.getField(cache, "targetCache")).isInstanceOf(RedisCache.class);
}
@Test // DATAREDIS-767
public void lockingCacheShouldPreventInFlightCacheCreation() {
RedisCacheManager cacheManager = RedisCacheManager.builder(cacheWriter).disableCreateOnMissingCache().build();
cacheManager.afterPropertiesSet();
assertThat(cacheManager.getCache("not-configured")).isNull();
}
@Test // DATAREDIS-767
public void lockingCacheShouldStillReturnPreconfiguredCaches() {
RedisCacheManager cacheManager = RedisCacheManager.builder(cacheWriter)
.initialCacheNames(Collections.singleton("configured")).disableCreateOnMissingCache().build();
cacheManager.afterPropertiesSet();
assertThat(cacheManager.getCache("configured")).isNotNull();
}
}