This commit is contained in:
luke 2025-06-20 16:18:58 +08:00
parent 19eec52e52
commit 4f439361b7

View File

@ -5,6 +5,7 @@ import com.knowledge.base.infrastructure.cache.iface.FileCacheService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.data.redis.core.Cursor;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -84,7 +85,7 @@ public class RedisFileCacheServiceImpl implements FileCacheService {
Set<String> keySet = new HashSet<>(); Set<String> keySet = new HashSet<>();
// 采用 scan分批遍历安全高效 // 采用 scan分批遍历安全高效
redisTemplate.execute((connection) -> { redisTemplate.execute((connection) -> {
try (var cursor = connection.scan(org.springframework.data.redis.core.ScanOptions.scanOptions() try (Cursor<byte[]> cursor = connection.scan(org.springframework.data.redis.core.ScanOptions.scanOptions()
.match(pattern) .match(pattern)
.count(1000) .count(1000)
.build())) { .build())) {