Add config.yaml value for cards cache capacity.

This commit is contained in:
Cohee
2024-12-05 12:59:03 +00:00
parent 41a3035a2a
commit 373a0ad321
3 changed files with 9 additions and 5 deletions

View File

@@ -680,8 +680,9 @@ export class MemoryLimitedMap {
* @param {number} maxMemoryInBytes - The maximum allowed memory in bytes for string values.
*/
constructor(maxMemoryInBytes) {
if (typeof maxMemoryInBytes !== 'number' || maxMemoryInBytes <= 0) {
throw new Error('maxMemoryInBytes must be a positive number');
if (typeof maxMemoryInBytes !== 'number' || maxMemoryInBytes <= 0 || isNaN(maxMemoryInBytes)) {
console.warn('Invalid maxMemoryInBytes, using a fallback value of 1 GB.');
maxMemoryInBytes = 1024 * 1024 * 1024; // 1 GB
}
this.maxMemory = maxMemoryInBytes;
this.currentMemory = 0;