From 6e4ea35877963ef0787830ff61d6351d0baa1359 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期日, 12 四月 2026 17:45:59 +0800
Subject: [PATCH] #日志采集优化
---
src/main/java/com/zy/common/utils/RedisUtil.java | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/zy/common/utils/RedisUtil.java b/src/main/java/com/zy/common/utils/RedisUtil.java
index 76ad76d..a51936c 100644
--- a/src/main/java/com/zy/common/utils/RedisUtil.java
+++ b/src/main/java/com/zy/common/utils/RedisUtil.java
@@ -215,6 +215,37 @@
}
}
+ public boolean multiSet(Map<String, Object> values, long time) {
+ if (values == null || values.isEmpty()) {
+ return true;
+ }
+ try {
+ redisTemplate.executePipelined((RedisCallback<Object>) connection -> {
+ for (Map.Entry<String, Object> entry : values.entrySet()) {
+ if (entry == null || entry.getKey() == null) {
+ continue;
+ }
+ byte[] keyBytes = redisTemplate.getStringSerializer().serialize(entry.getKey());
+ byte[] valueBytes = redisTemplate.getValueSerializer().serialize(entry.getValue());
+ if (keyBytes == null || valueBytes == null) {
+ continue;
+ }
+ if (time > 0) {
+ connection.stringCommands().setEx(keyBytes, time, valueBytes);
+ } else {
+ connection.stringCommands().set(keyBytes, valueBytes);
+ }
+ }
+ return null;
+ });
+ redisTemplate.execute((RedisCallback<Void>) connection -> null);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
/**
* 閫掑
*
--
Gitblit v1.9.1