feat: cache manager and webapp manifest repository
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package top.yeij.hearth.cache
|
||||
|
||||
import java.io.File
|
||||
|
||||
// 文件缓存:以 key 为文件名,内容以 UTF-8 纯文本落盘
|
||||
// File cache: uses key as filename, content stored as UTF-8 plain text
|
||||
class CacheManager(private val baseDir: File) {
|
||||
init { baseDir.mkdirs() }
|
||||
|
||||
fun save(key: String, content: String) {
|
||||
File(baseDir, key).writeText(content)
|
||||
}
|
||||
|
||||
fun load(key: String): String? {
|
||||
val f = File(baseDir, key)
|
||||
return if (f.exists()) f.readText() else null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user