MCPcopy
hub / github.com/msgbyte/tianji / getCacheManager

Function getCacheManager

src/server/cache/index.ts:7–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5
6let _cacheManager: Keyv;
7export async function getCacheManager() {
8 if (_cacheManager) {
9 return _cacheManager;
10 }
11
12 let store: KeyvStoreAdapter | undefined = undefined;
13 if (!env.cache.memoryOnly) {
14 store = env.cache.redisUrl
15 ? new KeyvRedis({
16 url: env.cache.redisUrl,
17 })
18 : new KeyvPostgres({
19 uri: env.db.url,
20 schema: 'cache',
21 table: 'cache',
22 });
23 }
24
25 const cacheManager = new Keyv({
26 store: store ?? new Map(),
27 ttl: 10 * 60 * 1000,
28 namespace: 'tianji-cache',
29 });
30
31 _cacheManager = cacheManager;
32
33 return cacheManager;
34}
35
36interface BuildQueryWithCacheOptions {
37 /**

Callers 15

getFunction · 0.85
updateFunction · 0.85
delFunction · 0.85
acquireMethod · 0.85
releaseMethod · 0.85
isLockedMethod · 0.85
getLockInfoMethod · 0.85
getServerMapFromCacheFunction · 0.85
saveServerMapToCacheFunction · 0.85
saveServerHistoryToCacheFunction · 0.85
getDailyCostFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected