()
| 114 | let storeInstance: IdempotencyStore | null = null; |
| 115 | |
| 116 | export function getIdempotencyStore(): IdempotencyStore { |
| 117 | if (storeInstance) return storeInstance; |
| 118 | const backend = isDatabaseInitialized() |
| 119 | ? pgBackend(getPool()) |
| 120 | : memoryBackend(); |
| 121 | storeInstance = createIdempotencyStore({ backend, ttlSeconds: REPLAY_TTL_SECONDS }); |
| 122 | return storeInstance; |
| 123 | } |
| 124 | |
| 125 | /** Reset the store — tests only. Safe to call when no store has been created. */ |
| 126 | export async function clearIdempotencyCache(): Promise<void> { |
no test coverage detected