|
@@ -148,15 +148,17 @@ public class ACache {
|
|
|
* @return String 数据
|
|
* @return String 数据
|
|
|
*/
|
|
*/
|
|
|
public String getAsString(String key) {
|
|
public String getAsString(String key) {
|
|
|
|
|
+ long time = System.currentTimeMillis();
|
|
|
File file = mCache.get(key);
|
|
File file = mCache.get(key);
|
|
|
if (!file.exists())
|
|
if (!file.exists())
|
|
|
return null;
|
|
return null;
|
|
|
- if (!key.contains("download_plugin") && System.currentTimeMillis() - file.lastModified() > TIME_HOUR/30) {
|
|
|
|
|
|
|
+ if (!key.contains("download_plugin") && System.currentTimeMillis() - file.lastModified() > TIME_HOUR) {
|
|
|
file.deleteOnExit();
|
|
file.deleteOnExit();
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
boolean removeFile = false;
|
|
boolean removeFile = false;
|
|
|
BufferedReader in = null;
|
|
BufferedReader in = null;
|
|
|
|
|
+ String result = null;
|
|
|
try {
|
|
try {
|
|
|
in = new BufferedReader(new FileReader(file));
|
|
in = new BufferedReader(new FileReader(file));
|
|
|
String readString = "";
|
|
String readString = "";
|
|
@@ -165,14 +167,12 @@ public class ACache {
|
|
|
readString += currentLine;
|
|
readString += currentLine;
|
|
|
}
|
|
}
|
|
|
if (!Utils.isDue(readString)) {
|
|
if (!Utils.isDue(readString)) {
|
|
|
- return Utils.clearDateInfo(readString);
|
|
|
|
|
|
|
+ result = Utils.clearDateInfo(readString);
|
|
|
} else {
|
|
} else {
|
|
|
removeFile = true;
|
|
removeFile = true;
|
|
|
- return null;
|
|
|
|
|
}
|
|
}
|
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
- return null;
|
|
|
|
|
} finally {
|
|
} finally {
|
|
|
if (in != null) {
|
|
if (in != null) {
|
|
|
try {
|
|
try {
|
|
@@ -181,8 +181,10 @@ public class ACache {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (removeFile)
|
|
|
|
|
|
|
+ if (removeFile) {
|
|
|
remove(key);
|
|
remove(key);
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -405,14 +407,13 @@ public class ACache {
|
|
|
if (data != null) {
|
|
if (data != null) {
|
|
|
ByteArrayInputStream bais = null;
|
|
ByteArrayInputStream bais = null;
|
|
|
ObjectInputStream ois = null;
|
|
ObjectInputStream ois = null;
|
|
|
|
|
+ Object reObject = null;
|
|
|
try {
|
|
try {
|
|
|
bais = new ByteArrayInputStream(data);
|
|
bais = new ByteArrayInputStream(data);
|
|
|
ois = new ObjectInputStream(bais);
|
|
ois = new ObjectInputStream(bais);
|
|
|
- Object reObject = ois.readObject();
|
|
|
|
|
- return reObject;
|
|
|
|
|
|
|
+ reObject = ois.readObject();
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
- return null;
|
|
|
|
|
} finally {
|
|
} finally {
|
|
|
try {
|
|
try {
|
|
|
if (bais != null)
|
|
if (bais != null)
|
|
@@ -426,10 +427,10 @@ public class ACache {
|
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
|
|
+ return reObject;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// =======================================
|
|
// =======================================
|