( redis: NonNullable<ReturnType<typeof getRedisClient>>, executionId: string, fileKey: string, rawEntry: string, entry: Base64BudgetEntry )
| 336 | } |
| 337 | |
| 338 | async function cleanupBudgetEntry( |
| 339 | redis: NonNullable<ReturnType<typeof getRedisClient>>, |
| 340 | executionId: string, |
| 341 | fileKey: string, |
| 342 | rawEntry: string, |
| 343 | entry: Base64BudgetEntry |
| 344 | ): Promise<{ claimed: boolean; deletedCount: number }> { |
| 345 | const limits = getExecutionRedisBudgetLimits() |
| 346 | const budgetReservation: ExecutionRedisBudgetReservation = { |
| 347 | executionId, |
| 348 | userId: entry.userId, |
| 349 | category: 'base64_cache', |
| 350 | operation: 'cleanup_base64_cache', |
| 351 | bytes: entry.bytes, |
| 352 | } |
| 353 | const budgetKeys = getExecutionRedisBudgetKeys(budgetReservation) |
| 354 | const result = (await redis.eval( |
| 355 | CLEANUP_BASE64_CACHE_ENTRY_SCRIPT, |
| 356 | 2 + budgetKeys.length, |
| 357 | getBudgetIndexKey(executionId), |
| 358 | `${REDIS_KEY_PREFIX}exec:${executionId}:${fileKey}`, |
| 359 | ...budgetKeys, |
| 360 | fileKey, |
| 361 | rawEntry, |
| 362 | entry.bytes, |
| 363 | limits.ttlSeconds |
| 364 | )) as [number, number] |
| 365 | return { claimed: Number(result[0]) === 1, deletedCount: Number(result[1] ?? 0) } |
| 366 | } |
| 367 | |
| 368 | function stripBase64(file: UserFile): UserFile { |
| 369 | const { base64: _base64, ...rest } = file |
no test coverage detected