Add support to clear cache by key pattern.
Closes #2379 Original pull request: #2380.
This commit is contained in:
@@ -61,6 +61,7 @@ import org.springframework.lang.Nullable;
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
* @author Piotr Mionskowski
|
||||
* @author Jos Roseboom
|
||||
*/
|
||||
@MethodSource("testParams")
|
||||
public class RedisCacheTests {
|
||||
@@ -108,6 +109,32 @@ public class RedisCacheTests {
|
||||
});
|
||||
}
|
||||
|
||||
@ParameterizedRedisTest // GH-2379
|
||||
void cacheShouldBeClearedByPattern() {
|
||||
|
||||
cache.put(key, sample);
|
||||
|
||||
final String keyPattern = "*" + key.substring(1);
|
||||
cache.clearByPattern(keyPattern);
|
||||
|
||||
doWithConnection(connection -> {
|
||||
assertThat(connection.exists(binaryCacheKey)).isFalse();
|
||||
});
|
||||
}
|
||||
|
||||
@ParameterizedRedisTest // GH-2379
|
||||
void cacheShouldNotBeClearedIfNoPatternMatch() {
|
||||
|
||||
cache.put(key, sample);
|
||||
|
||||
final String keyPattern = "*" + key.substring(1) + "tail";
|
||||
cache.clearByPattern(keyPattern);
|
||||
|
||||
doWithConnection(connection -> {
|
||||
assertThat(connection.exists(binaryCacheKey)).isTrue();
|
||||
});
|
||||
}
|
||||
|
||||
@ParameterizedRedisTest // DATAREDIS-481
|
||||
void putNullShouldAddEntryForNullValue() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user