@dismissible/nestjs-storage 1.0.1 → 1.0.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dismissible/nestjs-storage",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "In-memory storage adapter for Dismissible",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
"README.md"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@dismissible/nestjs-
|
|
20
|
-
"@dismissible/nestjs-
|
|
19
|
+
"@dismissible/nestjs-dismissible-item": "^1.0.2",
|
|
20
|
+
"@dismissible/nestjs-logger": "^1.0.2",
|
|
21
|
+
"lru-cache": "^11.2.4"
|
|
21
22
|
},
|
|
22
23
|
"peerDependencies": {
|
|
23
24
|
"@nestjs/common": "^10.0.0 || ^11.0.0"
|
|
@@ -2,8 +2,12 @@ import { IDismissibleLogger } from '@dismissible/nestjs-logger';
|
|
|
2
2
|
import { IDismissibleStorage } from './storage.interface';
|
|
3
3
|
import { DismissibleItemDto } from '@dismissible/nestjs-dismissible-item';
|
|
4
4
|
/**
|
|
5
|
-
* In-memory storage provider for dismissible items.
|
|
5
|
+
* In-memory storage provider for dismissible items with LRU eviction.
|
|
6
6
|
* Suitable for development and testing; not for production use.
|
|
7
|
+
*
|
|
8
|
+
* Automatically evicts items when:
|
|
9
|
+
* - The cache exceeds the maximum number of items (default: 5000)
|
|
10
|
+
* - Items are older than the maximum age (default: 6 hours)
|
|
7
11
|
*/
|
|
8
12
|
export declare class MemoryStorageAdapter implements IDismissibleStorage {
|
|
9
13
|
private readonly logger;
|
|
@@ -3,15 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MemoryStorageAdapter = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const common_1 = require("@nestjs/common");
|
|
6
|
+
const lru_cache_1 = require("lru-cache");
|
|
6
7
|
const nestjs_logger_1 = require("@dismissible/nestjs-logger");
|
|
7
8
|
/**
|
|
8
|
-
* In-memory storage provider for dismissible items.
|
|
9
|
+
* In-memory storage provider for dismissible items with LRU eviction.
|
|
9
10
|
* Suitable for development and testing; not for production use.
|
|
11
|
+
*
|
|
12
|
+
* Automatically evicts items when:
|
|
13
|
+
* - The cache exceeds the maximum number of items (default: 5000)
|
|
14
|
+
* - Items are older than the maximum age (default: 6 hours)
|
|
10
15
|
*/
|
|
11
16
|
let MemoryStorageAdapter = class MemoryStorageAdapter {
|
|
12
17
|
constructor(logger) {
|
|
13
18
|
this.logger = logger;
|
|
14
|
-
this.storage = new
|
|
19
|
+
this.storage = new lru_cache_1.LRUCache({
|
|
20
|
+
max: 5000,
|
|
21
|
+
ttl: 6 * 60 * 60 * 1000, // 6 hours
|
|
22
|
+
});
|
|
15
23
|
}
|
|
16
24
|
/**
|
|
17
25
|
* Create a storage key from userId and itemId.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-storage.adapter.js","sourceRoot":"","sources":["../../../../libs/storage/src/memory-storage.adapter.ts"],"names":[],"mappings":";;;;AAAA,2CAAoD;AACpD,8DAAoF;AAIpF
|
|
1
|
+
{"version":3,"file":"memory-storage.adapter.js","sourceRoot":"","sources":["../../../../libs/storage/src/memory-storage.adapter.ts"],"names":[],"mappings":";;;;AAAA,2CAAoD;AACpD,yCAAqC;AACrC,8DAAoF;AAIpF;;;;;;;GAOG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAG/B,YAAyD,MAA0B;QAA1B,WAAM,GAAN,MAAM,CAAoB;QACjF,IAAI,CAAC,OAAO,GAAG,IAAI,oBAAQ,CAA6B;YACtD,GAAG,EAAE,IAAI;YACT,GAAG,EAAE,CAAC,G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