移除~近似裁剪选项,替换成高级API调用

This commit is contained in:
hzj
2026-06-25 13:59:45 +08:00
parent 74f68c9680
commit fd9074de9b

View File

@@ -81,11 +81,11 @@ public class StreamTrimScheduler implements SmartLifecycle {
long maxlen = props.getTrim().getMaxlen();
for (String stream : distinctStreams()) {
try {
redis.execute((RedisCallback<Object>) connection -> connection.execute("XTRIM",
stream.getBytes(StandardCharsets.UTF_8),
"MAXLEN".getBytes(StandardCharsets.UTF_8),
"~".getBytes(StandardCharsets.UTF_8),
String.valueOf(maxlen).getBytes(StandardCharsets.UTF_8)));
redis.opsForStream().trim(stream,maxlen);
// redis.execute((RedisCallback<Object>) connection -> connection.execute("XTRIM",
// stream.getBytes(StandardCharsets.UTF_8),
// "MAXLEN".getBytes(StandardCharsets.UTF_8),
// String.valueOf(maxlen).getBytes(StandardCharsets.UTF_8)));
} catch (Exception e) {
log.warn("[redis-stream] trim failed stream={}", stream, e);
}