mirror of
https://github.com/labring/FastGPT.git
synced 2026-05-02 01:02:05 +08:00
4.13.1 features (#5728)
* fix(api): 修复二级路由下的页面判断逻辑 在请求错误处理中,添加基础URL前缀以正确判断当前是否为外部链接页面。 * perf: use global var * remove invalid code * feat: response limit;perf: copy avatar image;perf: markdown parse (#5719) * feat: response limit * remove placeholder * perf: copy avatar image * perf: markdown parse * fix: child app cannot show cite * doc * fix: node template bugs (#5727) * add dataset search count track (#5721) * add dataset search count track * remove pro * change to track * remove unused * fix * perf: track code --------- Co-authored-by: archer <545436317@qq.com> * http response limit * deploy doc * fix: test * doc * remove invalid code * remove invalid code --------- Co-authored-by: 戴盛利 <1639499287@qq.com> Co-authored-by: heheer <heheer@sealos.io>
This commit is contained in:
+9
-6
@@ -3,6 +3,7 @@ import { getGlobalRedisConnection } from '../../common/redis';
|
||||
import type { SystemCacheKeyEnum } from './type';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { initCache } from './init';
|
||||
import { isProduction } from '@fastgpt/global/common/system/constants';
|
||||
|
||||
const cachePrefix = `VERSION_KEY:`;
|
||||
|
||||
@@ -48,13 +49,15 @@ export const getCachedData = async <T extends SystemCacheKeyEnum>(key: T, id?: s
|
||||
const versionKey = await getVersionKey(key, id);
|
||||
const isDisableCache = process.env.DISABLE_CACHE === 'true';
|
||||
|
||||
const item = global.systemCache[key];
|
||||
|
||||
// 命中缓存
|
||||
if (global.systemCache[key].versionKey === versionKey && !isDisableCache) {
|
||||
return global.systemCache[key].data;
|
||||
if ((isProduction || !item.devRefresh) && item.versionKey === versionKey && !isDisableCache) {
|
||||
return item.data;
|
||||
}
|
||||
|
||||
const refreshedData = await global.systemCache[key].refreshFunc();
|
||||
global.systemCache[key].data = refreshedData;
|
||||
global.systemCache[key].versionKey = versionKey;
|
||||
return global.systemCache[key].data;
|
||||
const refreshedData = await item.refreshFunc();
|
||||
item.data = refreshedData;
|
||||
item.versionKey = versionKey;
|
||||
return item.data;
|
||||
};
|
||||
|
||||
+2
-1
@@ -6,7 +6,8 @@ export const initCache = () => {
|
||||
[SystemCacheKeyEnum.systemTool]: {
|
||||
versionKey: '',
|
||||
data: [],
|
||||
refreshFunc: refreshSystemTools
|
||||
refreshFunc: refreshSystemTools,
|
||||
devRefresh: true
|
||||
},
|
||||
[SystemCacheKeyEnum.modelPermission]: {
|
||||
versionKey: '',
|
||||
|
||||
+1
@@ -15,6 +15,7 @@ type SystemCacheType = {
|
||||
versionKey: string;
|
||||
data: SystemCacheDataType[K];
|
||||
refreshFunc: () => Promise<SystemCacheDataType[K]>;
|
||||
devRefresh?: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user