mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-15 23:38:32 +08:00
新增redis方法
This commit is contained in:
@@ -277,6 +277,8 @@ public class SpringBootTestController {
|
||||
@Qualifier("zhongDianLianPlatformServiceImpl")
|
||||
private ThirdPartyPlatformService platformLogic;
|
||||
|
||||
|
||||
|
||||
public void saveSOCTest() {
|
||||
String transactionCode = "12345";
|
||||
YKCUtils.saveSOC(transactionCode, "4");
|
||||
@@ -3883,4 +3885,13 @@ public class SpringBootTestController {
|
||||
System.out.println(StringUtils.equals(encryptData2, str));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addPileMsgTest() {
|
||||
String redisKey = "pile_msg_list:" + "88000000000002";
|
||||
for (int i = 0; i < 30; i++) {
|
||||
redisCache.addPileMsg(redisKey, "充电桩报文第" + i + "条") ;
|
||||
}
|
||||
System.out.println(redisCache.getCacheList(redisKey));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user