Skip to content

Commit 23d5834

Browse files
authored
Merge pull request #36867 from appsmithorg/cp/20241014-1
2 parents cf75cf5 + b086761 commit 23d5834

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration063CacheBustSpringBoot3_3.java

+26-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
import io.mongock.api.annotations.RollbackExecution;
66
import lombok.extern.slf4j.Slf4j;
77
import org.springframework.beans.factory.annotation.Qualifier;
8-
import org.springframework.data.redis.core.ReactiveRedisTemplate;
8+
import org.springframework.data.redis.core.ReactiveRedisOperations;
9+
import org.springframework.data.redis.core.ScanOptions;
10+
import reactor.core.publisher.Flux;
11+
import reactor.core.publisher.Mono;
12+
13+
import java.nio.ByteBuffer;
914

1015
@Slf4j
1116
@ChangeUnit(order = "063", id = "reset_session_oauth2_spring_3_3")
@@ -16,12 +21,25 @@ public void rollbackExecution() {}
1621

1722
@Execution
1823
public void execute(
19-
@Qualifier("reactiveRedisTemplate") final ReactiveRedisTemplate<String, Object> reactiveRedisTemplate) {
20-
reactiveRedisTemplate
21-
.getConnectionFactory()
22-
.getReactiveConnection()
23-
.serverCommands()
24-
.flushDb()
25-
.block();
24+
@Qualifier("reactiveRedisOperations") ReactiveRedisOperations<String, Object> reactiveRedisOperations) {
25+
scanForKeysAcrossCluster(reactiveRedisOperations, "*").block();
26+
}
27+
28+
private Mono<Void> scanForKeysAcrossCluster(
29+
ReactiveRedisOperations<String, Object> reactiveRedisOperations, String pattern) {
30+
return reactiveRedisOperations
31+
.execute(connection -> {
32+
Flux<ByteBuffer> scanFlux = connection
33+
.keyCommands()
34+
.scan(ScanOptions.scanOptions()
35+
.match(pattern)
36+
.count(1000)
37+
.build());
38+
return scanFlux.flatMap(scannedKey -> {
39+
return connection.keyCommands().del(scannedKey);
40+
})
41+
.then();
42+
})
43+
.then();
2644
}
2745
}

0 commit comments

Comments
 (0)