mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-17 23:16:50 +00:00
缓存优化
This commit is contained in:
8
lib/cache/local_file_cache.js
vendored
8
lib/cache/local_file_cache.js
vendored
@@ -40,3 +40,11 @@ export async function setCacheToFile (key, data) {
|
||||
json[key + '_expire_time'] = new Date().getTime()
|
||||
fs.writeFileSync(jsonFile, JSON.stringify(json))
|
||||
}
|
||||
|
||||
export async function delCacheFromFile (key, data) {
|
||||
const exist = await fs.existsSync(jsonFile)
|
||||
const json = exist ? JSON.parse(await fs.readFileSync(jsonFile)) : {}
|
||||
delete json.key
|
||||
json[key + '_expire_time'] = new Date().getTime()
|
||||
fs.writeFileSync(jsonFile, JSON.stringify(json))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user