| 46 | } |
| 47 | |
| 48 | replace(records: Iterable<unknown>, filter: RuntimeRecordCacheFilter = {}): RuntimeRecord[] { |
| 49 | if (Object.keys(filter).length > 0) { |
| 50 | for (const runtime of this.list(filter)) { |
| 51 | this.records.delete(runtime.runtimeId) |
| 52 | } |
| 53 | } else { |
| 54 | this.records.clear() |
| 55 | } |
| 56 | |
| 57 | const accepted: RuntimeRecord[] = [] |
| 58 | for (const record of records) { |
| 59 | const runtime = this.upsert(record) |
| 60 | if (runtime) accepted.push(runtime) |
| 61 | } |
| 62 | return accepted.sort(sortByUpdatedAtDesc) |
| 63 | } |
| 64 | |
| 65 | applyNotification(notification: RuntimeNotification): RuntimeRecord | null { |
| 66 | if (!RUNTIME_RECORD_NOTIFICATION_METHODS.has(notification.method)) return null |