| 13 | } |
| 14 | /** @deprecated Configure `createBot({ state })` instead. Action snapshots are stored via `StateStore.kv`. */ |
| 15 | export class InMemoryActionStore implements ActionStore { |
| 16 | private map = new Map<string, { snap: ActionSnapshot; expiresAt?: number }>(); |
| 17 | async put(id: string, snap: ActionSnapshot, ttlMs?: number): Promise<void> { |
| 18 | this.map.set(id, { |
| 19 | snap, |
| 20 | expiresAt: ttlMs ? Date.now() + ttlMs : undefined, |
| 21 | }); |
| 22 | } |
| 23 | async get(id: string): Promise<ActionSnapshot | undefined> { |
| 24 | const e = this.map.get(id); |
| 25 | if (!e) return undefined; |
| 26 | if (e.expiresAt !== undefined && Date.now() > e.expiresAt) { |
| 27 | this.map.delete(id); |
| 28 | return undefined; |
| 29 | } |
| 30 | return e.snap; |
| 31 | } |
| 32 | async delete(id: string): Promise<void> { |
| 33 | this.map.delete(id); |
| 34 | } |
| 35 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…