()
| 352 | } |
| 353 | |
| 354 | #prune () { |
| 355 | if (Number.isFinite(this.#maxCount) && this.size <= this.#maxCount) { |
| 356 | return 0 |
| 357 | } |
| 358 | |
| 359 | { |
| 360 | const removed = this.#deleteExpiredValuesQuery.run(Date.now()).changes |
| 361 | if (removed) { |
| 362 | return removed |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | { |
| 367 | const removed = this.#deleteOldValuesQuery?.run(Math.max(Math.floor(this.#maxCount * 0.1), 1)).changes |
| 368 | if (removed) { |
| 369 | return removed |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | return 0 |
| 374 | } |
| 375 | |
| 376 | /** |
| 377 | * Counts the number of rows in the cache |