MCPcopy Create free account
hub / github.com/Treeki/BirdBridge / UserCacheEntry

Class UserCacheEntry

utils/userCache.ts:17–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15}
16
17class UserCacheEntry {
18 status: Status;
19 promise: Promise<Record<string, any>>;
20 expiry?: number;
21
22 constructor(id: string, promise: Promise<Record<string, any>>) {
23 this.status = Status.WAITING;
24 this.promise = promise;
25 promise.then(_ => {
26 console.log('Fetched user ID ' + id);
27 this.status = Status.DONE;
28 this.expiry = (new Date().getTime()) + (60 * 1000);
29 }).catch(reason => {
30 console.error('Failed to fetch user', reason);
31 this.status = Status.FAILED;
32 });
33 }
34
35 get invalid() {
36 if (this.status === Status.FAILED)
37 return true;
38 if (this.expiry !== undefined && (new Date().getTime()) > this.expiry)
39 return true;
40 return false;
41 }
42}
43
44export class UserCache {
45 oauth: OAuth;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected