Fixes to NodeJS version.
This commit is contained in:
24
app-new/dist/backend/cache.js
vendored
Normal file
24
app-new/dist/backend/cache.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MemoryCache = void 0;
|
||||
class MemoryCache {
|
||||
store = new Map();
|
||||
get(key) {
|
||||
const hit = this.store.get(key);
|
||||
if (!hit) {
|
||||
return undefined;
|
||||
}
|
||||
if (Date.now() >= hit.expiresAt) {
|
||||
this.store.delete(key);
|
||||
return undefined;
|
||||
}
|
||||
return hit.value;
|
||||
}
|
||||
set(key, value, ttlMs) {
|
||||
this.store.set(key, {
|
||||
value,
|
||||
expiresAt: Date.now() + ttlMs
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.MemoryCache = MemoryCache;
|
||||
Reference in New Issue
Block a user