Commit 88b7daa6 authored by 李德才's avatar 李德才

添加Redis支持

parent 0ed72236
...@@ -4,6 +4,8 @@ package com.archser.aserver.service; ...@@ -4,6 +4,8 @@ package com.archser.aserver.service;
import com.archser.aserver.util.PropertyUtil; import com.archser.aserver.util.PropertyUtil;
import com.jfinal.kit.PathKit; import com.jfinal.kit.PathKit;
import com.jfinal.kit.PropKit; import com.jfinal.kit.PropKit;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.redis.Redis;
import java.io.File; import java.io.File;
...@@ -13,6 +15,7 @@ import java.io.File; ...@@ -13,6 +15,7 @@ import java.io.File;
public class SnService { public class SnService {
private static String FILE_PATH; private static String FILE_PATH;
private static final String PREFIX = "SN_";
static { static {
FILE_PATH = PathKit.getWebRootPath() + File.separator + "SN.properties"; FILE_PATH = PathKit.getWebRootPath() + File.separator + "SN.properties";
...@@ -26,7 +29,15 @@ public class SnService { ...@@ -26,7 +29,15 @@ public class SnService {
* @return * @return
*/ */
public String getPropertiesValue(String cupCode) { public String getPropertiesValue(String cupCode) {
return PropKit.use(new File(FILE_PATH)).get(cupCode); Object redisSnCode = Redis.use().get(PREFIX + cupCode);
if (redisSnCode != null) {
return redisSnCode.toString();
}
String fileSnCode = PropertyUtil.getProperty(cupCode, FILE_PATH);
if (StrKit.notBlank(fileSnCode)) {
saveSnToRedis(PREFIX + cupCode, fileSnCode);
}
return fileSnCode;
} }
...@@ -36,9 +47,13 @@ public class SnService { ...@@ -36,9 +47,13 @@ public class SnService {
* @param cupCode * @param cupCode
* @param snCode * @param snCode
*/ */
public void setProperty(String cupCode, String snCode) { public void setProperty(String cupCode, String snCode) {
PropertyUtil.setProperty(cupCode, snCode, FILE_PATH); PropertyUtil.setProperty(cupCode, snCode, FILE_PATH);
} }
public String saveSnToRedis(String cpuCode, String snCode) {
return Redis.use().set(cpuCode, snCode);
}
} }
#Tue Dec 01 16:02:59 CST 2020 #Tue Dec 01 16:30:09 CST 2020
AAAAAAAAAAAAAAA=cdcdcdcdcdc AAAAAAAAAAAAAAA=cdcdscdscsdcdc
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