| 173 | } |
| 174 | |
| 175 | class InMemoryBase64Cache implements Base64Cache { |
| 176 | private entries = new Map<string, { value: string; expiresAt: number }>() |
| 177 | |
| 178 | async get(file: UserFile): Promise<string | null> { |
| 179 | const key = getFileCacheKey(file) |
| 180 | const entry = this.entries.get(key) |
| 181 | if (!entry) { |
| 182 | return null |
| 183 | } |
| 184 | if (entry.expiresAt <= Date.now()) { |
| 185 | this.entries.delete(key) |
| 186 | return null |
| 187 | } |
| 188 | return entry.value |
| 189 | } |
| 190 | |
| 191 | async set(file: UserFile, value: string, ttlSeconds: number): Promise<void> { |
| 192 | const key = getFileCacheKey(file) |
| 193 | const expiresAt = Date.now() + ttlSeconds * 1000 |
| 194 | this.entries.set(key, { value, expiresAt }) |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | function createBase64Cache(options: Base64HydrationOptions, logger: Logger): Base64Cache { |
| 199 | const redis = getRedisClient() |
nothing calls this directly
no outgoing calls
no test coverage detected