cacheFile:首次下没有返回下载内容;ACache:saveTime=0视为永久保存

This commit is contained in:
Xwite 2022-01-07 10:13:20 +08:00
parent 61708f1e1c
commit 8211f73b43
2 changed files with 3 additions and 6 deletions

View File

@ -29,10 +29,7 @@ object CacheManager {
}
fun putString2File(key: String, value: String, saveTime: Int = 0) {
if (saveTime == 0) {
//不设置过期时间
ACache.get(appCtx).put(key, value)
} else ACache.get(appCtx).put(key, value, saveTime)
ACache.get(appCtx).put(key, value, saveTime)
}
fun get(key: String): String? {

View File

@ -109,7 +109,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
* @param saveTime 保存的时间单位
*/
fun put(key: String, value: String, saveTime: Int) {
put(key, Utils.newStringWithDateInfo(saveTime, value))
if (saveTime == 0) put(key, value) else put(key, Utils.newStringWithDateInfo(saveTime, value))
}
/**
@ -245,7 +245,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
* @param saveTime 保存的时间单位
*/
fun put(key: String, value: ByteArray, saveTime: Int) {
put(key, Utils.newByteArrayWithDateInfo(saveTime, value))
if (saveTime == 0) put(key, value) else put(key, Utils.newByteArrayWithDateInfo(saveTime, value))
}
/**