From c402e614bacc5999e7df19ee56b233e7cfe92683 Mon Sep 17 00:00:00 2001
From: 彭雪彬 <1724387007@qq.com>
Date: Thu, 04 Sep 2025 12:30:46 +0800
Subject: [PATCH] 骑手上传送达图片
---
oying-common/src/main/java/com/oying/utils/RedisUtils.java | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/oying-common/src/main/java/com/oying/utils/RedisUtils.java b/oying-common/src/main/java/com/oying/utils/RedisUtils.java
index 4467f18..361c573 100644
--- a/oying-common/src/main/java/com/oying/utils/RedisUtils.java
+++ b/oying-common/src/main/java/com/oying/utils/RedisUtils.java
@@ -392,6 +392,27 @@
}
}
+ /**
+ * 分布式ID生成器
+ *
+ * @param key 键
+ * @param value 值
+ * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期,注意:这里将会替换原有的时间
+ * @return true成功 false 失败
+ */
+ public boolean setIfAbsent(String key, Object value, long time) {
+ try {
+ if (time > 0) {
+ Boolean result = redisTemplate.opsForValue().setIfAbsent(key, value, time, TimeUnit.SECONDS);
+ return result;
+ } else {
+ return false;
+ }
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ return false;
+ }
+ }
// ================================Map=================================
/**
--
Gitblit v1.9.3