MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / getOrSet

Method getOrSet

src/app/cache.ts:125–132  ·  view source on GitHub ↗
(key: string, set: () => Promise<T> | T)

Source from the content-addressed store, hash-verified

123
124class Cache extends ExtCache {
125 public async getOrSet<T>(key: string, set: () => Promise<T> | T): Promise<T> {
126 let ret = await this.get<T>(key);
127 if (!ret) {
128 ret = await set();
129 this.set(key, ret);
130 }
131 return ret;
132 }
133
134 // 事务处理,如果有事务正在进行,则等待
135 public tx<T, CB extends (val: T | undefined, tx: { set: (newVal: T) => void; del: () => void }) => any>(

Callers 3

cache.test.tsFile · 0.80
queryPermissionMethod · 0.80
initManagerMethod · 0.80

Calls 2

setMethod · 0.95
setFunction · 0.50

Tested by

no test coverage detected