新增redis方法

This commit is contained in:
Guoqs
2024-11-28 15:35:48 +08:00
parent 2f438b0a12
commit 7c53dd66e0
2 changed files with 23 additions and 2 deletions

View File

@@ -1,7 +1,6 @@
package com.jsowell.common.core.redis;
import com.jsowell.common.util.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -27,7 +26,7 @@ public class RedisCache {
public RedisTemplate redisTemplate;
// redis锁获取超时时间
private long timeout = 500l;
private long timeout = 500L;
/**
* 缓存基本的对象Integer、String、实体类等
@@ -593,4 +592,15 @@ public class RedisCache {
return redisTemplate.opsForHash().increment(key, item, -by);
}
/**
* 添加充电桩消息到redis
*/
public void addPileMsg(String redisKey, String newData) {
// 执行左推操作
redisTemplate.opsForList().leftPush(redisKey, newData);
// 执行修剪操作限制列表的最大长度为10
redisTemplate.opsForList().trim(redisKey, 0, 9);
}
}