mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
feat(原生AI摘要功能支持缓存): 自定义缓存功能只支持memory,不支持文件缓存
(cherry picked from commit dd56dae44f7f555d9004e7d1f872085bded2cb86)
This commit is contained in:
4
lib/cache/cache_manager.js
vendored
4
lib/cache/cache_manager.js
vendored
@@ -20,12 +20,12 @@ export async function getDataFromCache(key, force) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function setDataToCache(key, data) {
|
||||
export async function setDataToCache(key, data, customCacheTime) {
|
||||
if (!data) {
|
||||
return
|
||||
}
|
||||
// console.trace('[API-->>缓存写入]:', key)
|
||||
await getApi().setCache(key, data)
|
||||
await getApi().setCache(key, data, customCacheTime)
|
||||
}
|
||||
|
||||
export async function delCacheData(key) {
|
||||
|
||||
4
lib/cache/memory_cache.js
vendored
4
lib/cache/memory_cache.js
vendored
@@ -7,8 +7,8 @@ export async function getCache(key, options) {
|
||||
return await cache.get(key)
|
||||
}
|
||||
|
||||
export async function setCache(key, data) {
|
||||
await cache.put(key, data, cacheTime * 1000)
|
||||
export async function setCache(key, data, customCacheTime) {
|
||||
await cache.put(key, data, (customCacheTime || cacheTime) * 1000)
|
||||
}
|
||||
|
||||
export async function delCache(key) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
export async function getAiSummary(aiSummaryAPI, aiSummaryKey, truncatedText) {
|
||||
try {
|
||||
console.log('请求文章摘要', truncatedText.slice(0, 100))
|
||||
const response = await fetch(aiSummaryAPI, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user