修复Redis返回默认值的问题

This commit is contained in:
yutou 2021-01-18 18:16:05 +08:00
parent d7a882cf8f
commit 45ce18edac
4 changed files with 4 additions and 12 deletions

View File

@ -9,7 +9,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication
public class ToolsApplication { public class ToolsApplication {
public static final String version="1.0.15.03"; public static final String version="1.0.15.04";
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("当前版本号:"+version); System.out.println("当前版本号:"+version);

View File

@ -248,7 +248,7 @@ public class BangumiTools {
*/ */
public static String reportToDayBangumi() { public static String reportToDayBangumi() {
String toDayTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); String toDayTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
if (!RedisTools.get("reportToDayBangumi").equals(toDayTime)) { if (!toDayTime.equals(RedisTools.get("reportToDayBangumi"))) {
RedisTools.set("reportToDayBangumi", toDayTime); RedisTools.set("reportToDayBangumi", toDayTime);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
JSONObject toDay = getBangumi(0); JSONObject toDay = getBangumi(0);

View File

@ -80,7 +80,7 @@ public class tools {
json.put("params", params); json.put("params", params);
json.put("cookie", cookies); json.put("cookie", cookies);
json.put("header", header); json.put("header", header);
Tools.sendServer("打印请求", json.toJSONString()); //Tools.sendServer("打印请求", json.toJSONString());
try { try {
switch (RedisTools.get("request")){ switch (RedisTools.get("request")){
case "success": case "success":

View File

@ -80,21 +80,13 @@ public class RedisTools {
if (isNotInstallRedis) { if (isNotInstallRedis) {
return value; return value;
} }
Jedis jedis = null; try (Jedis jedis = getRedis()) {
try {
jedis = getRedis();
jedis.select(dbIndex); jedis.select(dbIndex);
value = jedis.get(key); value = jedis.get(key);
jedis.close(); jedis.close();
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
// e.printStackTrace(); // e.printStackTrace();
} finally {
if (jedis != null)
jedis.close();
}
if(value==null){
value="-999";
} }
return value; return value;
} }