Add support to clear cache by key pattern.

Closes #2379
Original pull request: #2380.
This commit is contained in:
josroseboom
2022-08-01 10:17:33 +02:00
committed by Mark Paluch
parent 7469ce009a
commit f65ea0b1fb
2 changed files with 40 additions and 1 deletions

View File

@@ -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() {