DATAREDIS-1041 - Introduce RedisCache configuration option prefixCacheNameWith.

prefixCacheNameWith allows to prefix the cache name. The default CacheKeyPrefix.simple() format is still in place.

Original pull request: #507.
This commit is contained in:
Christoph Strobl
2020-01-10 12:59:05 +01:00
committed by Mark Paluch
parent f823062ef0
commit 94699ce79c
3 changed files with 61 additions and 2 deletions

View File

@@ -287,6 +287,22 @@ public class RedisCacheTests {
});
}
@Test // DATAREDIS-1041
public void prefixCacheNameCreatesCacheKeyCorrectly() {
RedisCache cacheWithCustomPrefix = new RedisCache("cache", new DefaultRedisCacheWriter(connectionFactory),
RedisCacheConfiguration.defaultCacheConfig().serializeValuesWith(SerializationPair.fromSerializer(serializer))
.prefixCacheNameWith("redis::"));
cacheWithCustomPrefix.put("key-1", sample);
doWithConnection(connection -> {
assertThat(connection.stringCommands().get("redis::cache::key-1".getBytes(StandardCharsets.UTF_8)))
.isEqualTo(binarySample);
});
}
@Test // DATAREDIS-715
public void fetchKeyWithComputedPrefixReturnsExpectedResult() {