mirror of
https://github.com/EmulatorJS/EmulatorJS.git
synced 2026-02-06 11:17:36 +00:00
Implement startup cleanup for cache retrieval in EJS_Cache
This commit is contained in:
parent
e74fb401c2
commit
cbb7228a78
@ -35,6 +35,11 @@ class EJS_Cache {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the startup cleanup has been completed.
|
||||
*/
|
||||
#startupCleanupCompleted = false;
|
||||
|
||||
/**
|
||||
* Generates a cache key for the given data array.
|
||||
* @param {Uint8Array} dataArray
|
||||
@ -55,6 +60,12 @@ class EJS_Cache {
|
||||
async get(key, metadataOnly = false) {
|
||||
if (!this.enabled) return null;
|
||||
|
||||
// clean up cache on first get if not already done
|
||||
if (!this.#startupCleanupCompleted) {
|
||||
await this.cleanup();
|
||||
this.#startupCleanupCompleted = true;
|
||||
}
|
||||
|
||||
const item = await this.storage.get(key);
|
||||
// if the item exists, update its lastAccessed time and return cache item
|
||||
if (item) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user