Refactor cache entry removal to use Set for removalQueue

60e4993a89936288007034406221b4292f7be940

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +5 -5Ignore whitespace
src/endpoints/characters.js+5 -5
@@ -50,7 +50,7 @@ const diskCache = {
5050 */
5151 _removeCacheEntries: async function() {
5252 try {
5353 if (!useDiskCache || this.removalQueue.lengthsize === 0) {
5454 return;
5555 }
5656
@@ -62,7 +62,7 @@ const diskCache = {
6262 }
6363 }
6464 console.info('Removed cache entries:', this.removalQueue);
6565 this.removalQueue = [].clear();
6666 } catch (error) {
6767 console.error('Error while removing cache entries:', error);
6868 }
@@ -84,9 +84,9 @@ const diskCache = {
8484 },
8585 /**
8686 * Queue for removal of cache entries.
8787 * @type {Set<string[]>}
8888 */
8989 removalQueue: []new Set(),
9090};
9191
9292/**
@@ -166,7 +166,7 @@ async function writeCharacterData(inputFile, data, outputFile, request, crop = u
166166 }
167167 }
168168 if (useDiskCache && !Buffer.isBuffer(inputFile)) {
169169 diskCache.removalQueue.pushadd(inputFile);
170170 }
171171 /**
172172 * Read the image, resize, and save it as a PNG into the buffer.