@superatomai/sdk-node 0.0.41-mds → 0.0.42-mds
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1476,7 +1476,7 @@ var QueryCache = class {
|
|
|
1476
1476
|
this.cache = /* @__PURE__ */ new Map();
|
|
1477
1477
|
this.ttlMs = 10 * 60 * 1e3;
|
|
1478
1478
|
// Default: 10 minutes
|
|
1479
|
-
this.maxCacheSize =
|
|
1479
|
+
this.maxCacheSize = 5e3;
|
|
1480
1480
|
// Max data cache entries
|
|
1481
1481
|
this.cleanupInterval = null;
|
|
1482
1482
|
// Encryption for queryId tokens
|
|
@@ -1503,9 +1503,13 @@ var QueryCache = class {
|
|
|
1503
1503
|
return this.ttlMs / 60 / 1e3;
|
|
1504
1504
|
}
|
|
1505
1505
|
/**
|
|
1506
|
-
* Store query result in data cache
|
|
1506
|
+
* Store query result in data cache.
|
|
1507
|
+
* If the key already exists, it's removed first so the re-insert places it
|
|
1508
|
+
* at the back of the iteration order (LRU). Eviction only fires when adding
|
|
1509
|
+
* a genuinely new key past the size limit.
|
|
1507
1510
|
*/
|
|
1508
1511
|
set(query, data) {
|
|
1512
|
+
this.cache.delete(query);
|
|
1509
1513
|
if (this.cache.size >= this.maxCacheSize) {
|
|
1510
1514
|
const oldestKey = this.cache.keys().next().value;
|
|
1511
1515
|
if (oldestKey) this.cache.delete(oldestKey);
|
|
@@ -1518,7 +1522,9 @@ var QueryCache = class {
|
|
|
1518
1522
|
logger.debug(`[QueryCache] Stored result for query (${query.substring(0, 50)}...)`);
|
|
1519
1523
|
}
|
|
1520
1524
|
/**
|
|
1521
|
-
* Get cached result if exists and not expired
|
|
1525
|
+
* Get cached result if exists and not expired.
|
|
1526
|
+
* On hit, re-inserts the entry so it moves to the back of the Map's
|
|
1527
|
+
* iteration order — turning FIFO eviction into true LRU.
|
|
1522
1528
|
*/
|
|
1523
1529
|
get(query) {
|
|
1524
1530
|
const entry = this.cache.get(query);
|
|
@@ -1527,6 +1533,8 @@ var QueryCache = class {
|
|
|
1527
1533
|
this.cache.delete(query);
|
|
1528
1534
|
return null;
|
|
1529
1535
|
}
|
|
1536
|
+
this.cache.delete(query);
|
|
1537
|
+
this.cache.set(query, entry);
|
|
1530
1538
|
logger.info(`[QueryCache] Cache HIT for query (${query.substring(0, 50)}...)`);
|
|
1531
1539
|
return entry.data;
|
|
1532
1540
|
}
|