Commit 2f4aa601 authored by alex yao's avatar alex yao

fix:NPE

parent a38cec25
......@@ -55,7 +55,7 @@ public class SetLongMemoryFunction extends AbstractLargeModelFunction {
JSONObject jsonObject = new JSONObject(content);
// 提取 content
String contents = jsonObject.getStr("content");
String contentKey = SetLongMemoryConstants.REDIS_PREFIX + key + ":" + BlContext.getCurrentUserNotException().getUserId().toString();
String contentKey = SetLongMemoryConstants.REDIS_PREFIX + key;
redisService.hset(contentKey, DateUtils.getCurrTime(), contents, expireTime);
return "SUCCESS";
}
......
......@@ -12,7 +12,7 @@ import java.util.Map;
public class MemoryVariableWriter {
public static Map<Object, Object> get(String key) {
String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + key + ":" + BlContext.getCurrentUserNotException().getUserId().toString();
String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + key;
RedisService redisService = SpringUtils.getBean(RedisService.class);
if (!redisService.hasKey(redisKey)) {
return null;
......@@ -22,25 +22,25 @@ public class MemoryVariableWriter {
}
public static void clean(String key) {
String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + key + ":" + BlContext.getCurrentUserNotException().getUserId().toString();
String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + key;
RedisService redisService = SpringUtils.getBean(RedisService.class);
redisService.del(redisKey);
}
public static void cleanByPre(String key) {
String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + key + ":";
String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + key;
RedisService redisService = SpringUtils.getBean(RedisService.class);
redisService.delByPre(redisKey);
}
public static void delItem(String identifier, String... items) {
String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + identifier + ":" + BlContext.getCurrentUserNotException().getUserId().toString();
String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + identifier;
RedisService redisService = SpringUtils.getBean(RedisService.class);
redisService.hdel(redisKey, items);
}
public static void addItem(String identifier, Map<String, Object> map) {
String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + identifier + ":" + BlContext.getCurrentUserNotException().getUserId().toString();
String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + identifier;
RedisService redisService = SpringUtils.getBean(RedisService.class);
// 创建 JSONObject 对象
Map<String, Object> result = new HashMap<>();
......
......@@ -45,7 +45,7 @@ public class MemoryVariableWriterFunction extends AbstractLargeModelFunction {
if (StringUtils.isBlank(content) || StringUtils.isBlank(identifier)) {
return "FAIL";
}
String contentKey = MemoryVariableWriterConstants.REDIS_PREFIX + identifier + ":" + BlContext.getCurrentUserNotException().getUserId().toString();
String contentKey = MemoryVariableWriterConstants.REDIS_PREFIX + identifier;
// 创建 JSONObject 对象
Map<String, Object> result = new HashMap<>();
if (redisService.hasKey(contentKey)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment