(key: string, set: () => Promise<T> | T)
| 123 | |
| 124 | class 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>( |
no test coverage detected