@nestjs-redisx/cache 1.0.3 → 1.0.5
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/cache/api/decorators/cached.decorator.d.ts.map +1 -1
- package/dist/cache/application/services/cache-decorator-initializer.service.d.ts.map +1 -1
- package/dist/index.js +49 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cached.decorator.d.ts","sourceRoot":"","sources":["../../../../src/cache/api/decorators/cached.decorator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"cached.decorator.d.ts","sourceRoot":"","sources":["../../../../src/cache/api/decorators/cached.decorator.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-decorator-initializer.service.d.ts","sourceRoot":"","sources":["../../../../src/cache/application/services/cache-decorator-initializer.service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAc,YAAY,EAA4B,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,iEAAiE,CAAC;AAG5G,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,qBACa,gCAAiC,YAAW,YAAY;
|
|
1
|
+
{"version":3,"file":"cache-decorator-initializer.service.d.ts","sourceRoot":"","sources":["../../../../src/cache/application/services/cache-decorator-initializer.service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAc,YAAY,EAA4B,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,iEAAiE,CAAC;AAG5G,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,qBACa,gCAAiC,YAAW,YAAY;IAI9C,OAAO,CAAC,QAAQ,CAAC,SAAS;IACtB,OAAO,CAAC,QAAQ,CAAC,YAAY;IACtB,OAAO,CAAC,QAAQ,CAAC,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IAN5F,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqD;gBAGtC,SAAS,EAAE,SAAS,EAChB,YAAY,EAAE,aAAa,EACpB,aAAa,EAAE,mBAAmB,EAChB,wBAAwB,CAAC,EAAE,yBAAyB,YAAA;IAGvH;;;OAGG;IAEG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAkBpC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var core
|
|
3
|
+
var core = require('@nestjs/core');
|
|
4
4
|
var common = require('@nestjs/common');
|
|
5
5
|
require('reflect-metadata');
|
|
6
|
-
var core = require('@nestjs-redisx/core');
|
|
7
6
|
var crypto = require('crypto');
|
|
7
|
+
var core$1 = require('@nestjs-redisx/core');
|
|
8
8
|
var events = require('events');
|
|
9
9
|
var rxjs = require('rxjs');
|
|
10
10
|
var operators = require('rxjs/operators');
|
|
@@ -26,7 +26,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
26
26
|
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
27
27
|
|
|
28
28
|
// package.json
|
|
29
|
-
var version = "1.0.
|
|
29
|
+
var version = "1.0.4";
|
|
30
30
|
|
|
31
31
|
// src/shared/constants/index.ts
|
|
32
32
|
var CACHE_PLUGIN_OPTIONS = /* @__PURE__ */ Symbol.for("CACHE_PLUGIN_OPTIONS");
|
|
@@ -210,13 +210,17 @@ function serializeArg(arg) {
|
|
|
210
210
|
}
|
|
211
211
|
if (typeof arg === "object") {
|
|
212
212
|
try {
|
|
213
|
-
|
|
213
|
+
const stable = stableStringify(arg);
|
|
214
|
+
return hashForKey(stable);
|
|
214
215
|
} catch {
|
|
215
216
|
return "object";
|
|
216
217
|
}
|
|
217
218
|
}
|
|
218
219
|
return "unknown";
|
|
219
220
|
}
|
|
221
|
+
function hashForKey(input) {
|
|
222
|
+
return crypto.createHash("sha256").update(input).digest("hex").slice(0, 16);
|
|
223
|
+
}
|
|
220
224
|
function stableStringify(value) {
|
|
221
225
|
if (value === null || value === void 0) {
|
|
222
226
|
return "null";
|
|
@@ -352,40 +356,41 @@ var CacheDecoratorInitializerService = class {
|
|
|
352
356
|
};
|
|
353
357
|
CacheDecoratorInitializerService = __decorateClass([
|
|
354
358
|
common.Injectable(),
|
|
359
|
+
__decorateParam(0, common.Inject(core.ModuleRef)),
|
|
355
360
|
__decorateParam(1, common.Inject(CACHE_SERVICE)),
|
|
356
361
|
__decorateParam(2, common.Inject(CACHE_PLUGIN_OPTIONS)),
|
|
357
362
|
__decorateParam(3, common.Optional()),
|
|
358
363
|
__decorateParam(3, common.Inject(EVENT_INVALIDATION_SERVICE))
|
|
359
364
|
], CacheDecoratorInitializerService);
|
|
360
|
-
var CacheError = class extends core.RedisXError {
|
|
361
|
-
constructor(message, code = core.ErrorCode.OPERATION_FAILED, cause) {
|
|
365
|
+
var CacheError = class extends core$1.RedisXError {
|
|
366
|
+
constructor(message, code = core$1.ErrorCode.OPERATION_FAILED, cause) {
|
|
362
367
|
super(message, code, cause);
|
|
363
368
|
this.name = "CacheError";
|
|
364
369
|
}
|
|
365
370
|
};
|
|
366
371
|
var CacheKeyError = class extends CacheError {
|
|
367
372
|
constructor(key, message) {
|
|
368
|
-
super(`Invalid cache key "${key}": ${message}`, core.ErrorCode.CACHE_KEY_INVALID);
|
|
373
|
+
super(`Invalid cache key "${key}": ${message}`, core$1.ErrorCode.CACHE_KEY_INVALID);
|
|
369
374
|
this.key = key;
|
|
370
375
|
this.name = "CacheKeyError";
|
|
371
376
|
}
|
|
372
377
|
};
|
|
373
378
|
var SerializationError = class extends CacheError {
|
|
374
379
|
constructor(message, cause) {
|
|
375
|
-
super(`Serialization error: ${message}`, core.ErrorCode.SERIALIZATION_FAILED, cause);
|
|
380
|
+
super(`Serialization error: ${message}`, core$1.ErrorCode.SERIALIZATION_FAILED, cause);
|
|
376
381
|
this.name = "SerializationError";
|
|
377
382
|
}
|
|
378
383
|
};
|
|
379
384
|
var LoaderError = class extends CacheError {
|
|
380
385
|
constructor(key, cause) {
|
|
381
|
-
super(`Loader failed for key "${key}": ${cause.message}`, core.ErrorCode.OPERATION_FAILED, cause);
|
|
386
|
+
super(`Loader failed for key "${key}": ${cause.message}`, core$1.ErrorCode.OPERATION_FAILED, cause);
|
|
382
387
|
this.key = key;
|
|
383
388
|
this.name = "LoaderError";
|
|
384
389
|
}
|
|
385
390
|
};
|
|
386
391
|
var StampedeError = class extends CacheError {
|
|
387
392
|
constructor(key, timeout) {
|
|
388
|
-
super(`Stampede protection timeout for key "${key}" after ${timeout}ms`, core.ErrorCode.OPERATION_TIMEOUT);
|
|
393
|
+
super(`Stampede protection timeout for key "${key}" after ${timeout}ms`, core$1.ErrorCode.OPERATION_TIMEOUT);
|
|
389
394
|
this.key = key;
|
|
390
395
|
this.timeout = timeout;
|
|
391
396
|
this.name = "StampedeError";
|
|
@@ -393,7 +398,7 @@ var StampedeError = class extends CacheError {
|
|
|
393
398
|
};
|
|
394
399
|
var TagInvalidationError = class extends CacheError {
|
|
395
400
|
constructor(tag, message, cause) {
|
|
396
|
-
super(`Tag invalidation failed for "${tag}": ${message}`, core.ErrorCode.OPERATION_FAILED, cause);
|
|
401
|
+
super(`Tag invalidation failed for "${tag}": ${message}`, core$1.ErrorCode.OPERATION_FAILED, cause);
|
|
397
402
|
this.tag = tag;
|
|
398
403
|
this.name = "TagInvalidationError";
|
|
399
404
|
}
|
|
@@ -571,20 +576,20 @@ var Tag = class _Tag {
|
|
|
571
576
|
*/
|
|
572
577
|
static create(value, maxLength = DEFAULT_MAX_LENGTH) {
|
|
573
578
|
if (!value || value.length === 0) {
|
|
574
|
-
throw new CacheError("Tag cannot be empty", core.ErrorCode.CACHE_KEY_INVALID);
|
|
579
|
+
throw new CacheError("Tag cannot be empty", core$1.ErrorCode.CACHE_KEY_INVALID);
|
|
575
580
|
}
|
|
576
581
|
const normalized = value.trim().toLowerCase();
|
|
577
582
|
if (normalized.length === 0) {
|
|
578
|
-
throw new CacheError("Tag cannot be empty after normalization", core.ErrorCode.CACHE_KEY_INVALID);
|
|
583
|
+
throw new CacheError("Tag cannot be empty after normalization", core$1.ErrorCode.CACHE_KEY_INVALID);
|
|
579
584
|
}
|
|
580
585
|
if (/\s/.test(normalized)) {
|
|
581
|
-
throw new CacheError("Tag cannot contain whitespace", core.ErrorCode.CACHE_KEY_INVALID);
|
|
586
|
+
throw new CacheError("Tag cannot contain whitespace", core$1.ErrorCode.CACHE_KEY_INVALID);
|
|
582
587
|
}
|
|
583
588
|
if (!/^[a-z0-9\-_:.]+$/.test(normalized)) {
|
|
584
|
-
throw new CacheError("Invalid tag characters. Only lowercase alphanumeric, hyphens, underscores, colons, and dots allowed", core.ErrorCode.CACHE_KEY_INVALID);
|
|
589
|
+
throw new CacheError("Invalid tag characters. Only lowercase alphanumeric, hyphens, underscores, colons, and dots allowed", core$1.ErrorCode.CACHE_KEY_INVALID);
|
|
585
590
|
}
|
|
586
591
|
if (normalized.length > maxLength) {
|
|
587
|
-
throw new CacheError(`Tag exceeds maximum length (${normalized.length} > ${maxLength})`, core.ErrorCode.CACHE_KEY_INVALID);
|
|
592
|
+
throw new CacheError(`Tag exceeds maximum length (${normalized.length} > ${maxLength})`, core$1.ErrorCode.CACHE_KEY_INVALID);
|
|
588
593
|
}
|
|
589
594
|
return new _Tag(normalized);
|
|
590
595
|
}
|
|
@@ -628,7 +633,7 @@ var Tags = class _Tags {
|
|
|
628
633
|
*/
|
|
629
634
|
static create(values, maxTags = DEFAULT_MAX_TAGS) {
|
|
630
635
|
if (values.length > maxTags) {
|
|
631
|
-
throw new CacheError(`Too many tags (${values.length} > ${maxTags})`, core.ErrorCode.CACHE_KEY_INVALID);
|
|
636
|
+
throw new CacheError(`Too many tags (${values.length} > ${maxTags})`, core$1.ErrorCode.CACHE_KEY_INVALID);
|
|
632
637
|
}
|
|
633
638
|
const tagObjects = values.map((v) => Tag.create(v));
|
|
634
639
|
const uniqueValues = Array.from(new Set(tagObjects.map((t) => t.toString())));
|
|
@@ -699,10 +704,10 @@ var TTL = class _TTL {
|
|
|
699
704
|
*/
|
|
700
705
|
static create(seconds, maxTtl = DEFAULT_MAX_TTL_SECONDS) {
|
|
701
706
|
if (seconds <= 0) {
|
|
702
|
-
throw new CacheError(`TTL must be positive (got ${seconds})`, core.ErrorCode.CACHE_KEY_INVALID);
|
|
707
|
+
throw new CacheError(`TTL must be positive (got ${seconds})`, core$1.ErrorCode.CACHE_KEY_INVALID);
|
|
703
708
|
}
|
|
704
709
|
if (seconds > maxTtl) {
|
|
705
|
-
throw new CacheError(`TTL exceeds maximum (${seconds} > ${maxTtl})`, core.ErrorCode.CACHE_KEY_INVALID);
|
|
710
|
+
throw new CacheError(`TTL exceeds maximum (${seconds} > ${maxTtl})`, core$1.ErrorCode.CACHE_KEY_INVALID);
|
|
706
711
|
}
|
|
707
712
|
const rounded = Math.round(seconds);
|
|
708
713
|
return new _TTL(rounded);
|
|
@@ -880,7 +885,7 @@ var CacheService = class {
|
|
|
880
885
|
if (error instanceof CacheKeyError || error instanceof CacheError) {
|
|
881
886
|
throw error;
|
|
882
887
|
}
|
|
883
|
-
throw new CacheError(`Failed to set cache for key "${key}": ${error.message}`, core.ErrorCode.CACHE_SET_FAILED, error);
|
|
888
|
+
throw new CacheError(`Failed to set cache for key "${key}": ${error.message}`, core$1.ErrorCode.CACHE_SET_FAILED, error);
|
|
884
889
|
} finally {
|
|
885
890
|
span?.end();
|
|
886
891
|
}
|
|
@@ -985,7 +990,7 @@ var CacheService = class {
|
|
|
985
990
|
if (error instanceof CacheKeyError) {
|
|
986
991
|
throw error;
|
|
987
992
|
}
|
|
988
|
-
throw new CacheError(`Failed to delete cache for key "${key}": ${error.message}`, core.ErrorCode.CACHE_DELETE_FAILED, error);
|
|
993
|
+
throw new CacheError(`Failed to delete cache for key "${key}": ${error.message}`, core$1.ErrorCode.CACHE_DELETE_FAILED, error);
|
|
989
994
|
}
|
|
990
995
|
}
|
|
991
996
|
async deleteMany(keys) {
|
|
@@ -1033,7 +1038,7 @@ var CacheService = class {
|
|
|
1033
1038
|
}
|
|
1034
1039
|
return deleted.filter(Boolean).length;
|
|
1035
1040
|
} catch (error) {
|
|
1036
|
-
throw new CacheError(`Failed to delete multiple keys: ${error.message}`, core.ErrorCode.CACHE_DELETE_FAILED, error);
|
|
1041
|
+
throw new CacheError(`Failed to delete multiple keys: ${error.message}`, core$1.ErrorCode.CACHE_DELETE_FAILED, error);
|
|
1037
1042
|
}
|
|
1038
1043
|
}
|
|
1039
1044
|
async clear() {
|
|
@@ -1048,7 +1053,7 @@ var CacheService = class {
|
|
|
1048
1053
|
await this.tagIndex.clearAllTags();
|
|
1049
1054
|
}
|
|
1050
1055
|
} catch (error) {
|
|
1051
|
-
throw new CacheError(`Failed to clear cache: ${error.message}`, core.ErrorCode.CACHE_CLEAR_FAILED, error);
|
|
1056
|
+
throw new CacheError(`Failed to clear cache: ${error.message}`, core$1.ErrorCode.CACHE_CLEAR_FAILED, error);
|
|
1052
1057
|
}
|
|
1053
1058
|
}
|
|
1054
1059
|
async has(key) {
|
|
@@ -1082,7 +1087,7 @@ var CacheService = class {
|
|
|
1082
1087
|
}
|
|
1083
1088
|
return await this.tagIndex.invalidateTag(tag);
|
|
1084
1089
|
} catch (error) {
|
|
1085
|
-
throw new CacheError(`Failed to invalidate tag "${tag}": ${error.message}`, core.ErrorCode.CACHE_TAG_INVALIDATION_FAILED, error);
|
|
1090
|
+
throw new CacheError(`Failed to invalidate tag "${tag}": ${error.message}`, core$1.ErrorCode.CACHE_TAG_INVALIDATION_FAILED, error);
|
|
1086
1091
|
}
|
|
1087
1092
|
}
|
|
1088
1093
|
async invalidateTags(tags) {
|
|
@@ -1097,7 +1102,7 @@ var CacheService = class {
|
|
|
1097
1102
|
}
|
|
1098
1103
|
return total;
|
|
1099
1104
|
} catch (error) {
|
|
1100
|
-
throw new CacheError(`Failed to invalidate tags: ${error.message}`, core.ErrorCode.CACHE_TAG_INVALIDATION_FAILED, error);
|
|
1105
|
+
throw new CacheError(`Failed to invalidate tags: ${error.message}`, core$1.ErrorCode.CACHE_TAG_INVALIDATION_FAILED, error);
|
|
1101
1106
|
}
|
|
1102
1107
|
}
|
|
1103
1108
|
async getKeysByTag(tag) {
|
|
@@ -1192,7 +1197,7 @@ var CacheService = class {
|
|
|
1192
1197
|
if (error instanceof CacheKeyError) {
|
|
1193
1198
|
throw error;
|
|
1194
1199
|
}
|
|
1195
|
-
throw new CacheError(`Failed to setMany: ${error.message}`, core.ErrorCode.CACHE_SET_FAILED, error);
|
|
1200
|
+
throw new CacheError(`Failed to setMany: ${error.message}`, core$1.ErrorCode.CACHE_SET_FAILED, error);
|
|
1196
1201
|
}
|
|
1197
1202
|
}
|
|
1198
1203
|
async ttl(key) {
|
|
@@ -1243,7 +1248,7 @@ var CacheService = class {
|
|
|
1243
1248
|
}
|
|
1244
1249
|
return deleted;
|
|
1245
1250
|
} catch (error) {
|
|
1246
|
-
throw new CacheError(`Failed to invalidate by pattern "${pattern}": ${error.message}`, core.ErrorCode.CACHE_DELETE_FAILED, error);
|
|
1251
|
+
throw new CacheError(`Failed to invalidate by pattern "${pattern}": ${error.message}`, core$1.ErrorCode.CACHE_DELETE_FAILED, error);
|
|
1247
1252
|
}
|
|
1248
1253
|
}
|
|
1249
1254
|
/**
|
|
@@ -1324,7 +1329,7 @@ var CacheService = class {
|
|
|
1324
1329
|
};
|
|
1325
1330
|
CacheService = __decorateClass([
|
|
1326
1331
|
common.Injectable(),
|
|
1327
|
-
__decorateParam(0, common.Inject(core.REDIS_DRIVER)),
|
|
1332
|
+
__decorateParam(0, common.Inject(core$1.REDIS_DRIVER)),
|
|
1328
1333
|
__decorateParam(1, common.Inject(L1_CACHE_STORE)),
|
|
1329
1334
|
__decorateParam(2, common.Inject(L2_CACHE_STORE)),
|
|
1330
1335
|
__decorateParam(3, common.Inject(STAMPEDE_PROTECTION)),
|
|
@@ -1645,7 +1650,7 @@ var L2RedisStoreAdapter = class {
|
|
|
1645
1650
|
const ttlSeconds = ttl ?? this.defaultTtl;
|
|
1646
1651
|
await this.driver.setex(fullKey, ttlSeconds, serialized);
|
|
1647
1652
|
} catch (error) {
|
|
1648
|
-
throw new CacheError(`Failed to set cache entry for key "${key}": ${error.message}`, core.ErrorCode.CACHE_SET_FAILED, error);
|
|
1653
|
+
throw new CacheError(`Failed to set cache entry for key "${key}": ${error.message}`, core$1.ErrorCode.CACHE_SET_FAILED, error);
|
|
1649
1654
|
}
|
|
1650
1655
|
}
|
|
1651
1656
|
async delete(key) {
|
|
@@ -1654,7 +1659,7 @@ var L2RedisStoreAdapter = class {
|
|
|
1654
1659
|
const result = await this.driver.del(fullKey);
|
|
1655
1660
|
return result > 0;
|
|
1656
1661
|
} catch (error) {
|
|
1657
|
-
throw new CacheError(`Failed to delete cache entry for key "${key}": ${error.message}`, core.ErrorCode.CACHE_DELETE_FAILED, error);
|
|
1662
|
+
throw new CacheError(`Failed to delete cache entry for key "${key}": ${error.message}`, core$1.ErrorCode.CACHE_DELETE_FAILED, error);
|
|
1658
1663
|
}
|
|
1659
1664
|
}
|
|
1660
1665
|
async clear() {
|
|
@@ -1670,7 +1675,7 @@ var L2RedisStoreAdapter = class {
|
|
|
1670
1675
|
await Promise.all(batch.map((key) => this.driver.del(key)));
|
|
1671
1676
|
}
|
|
1672
1677
|
} catch (error) {
|
|
1673
|
-
throw new CacheError(`Failed to clear cache: ${error.message}`, core.ErrorCode.CACHE_CLEAR_FAILED, error);
|
|
1678
|
+
throw new CacheError(`Failed to clear cache: ${error.message}`, core$1.ErrorCode.CACHE_CLEAR_FAILED, error);
|
|
1674
1679
|
}
|
|
1675
1680
|
}
|
|
1676
1681
|
async has(key) {
|
|
@@ -1697,7 +1702,7 @@ var L2RedisStoreAdapter = class {
|
|
|
1697
1702
|
const result = await this.driver.expire(fullKey, ttl);
|
|
1698
1703
|
return result === 1;
|
|
1699
1704
|
} catch (error) {
|
|
1700
|
-
throw new CacheError(`Failed to set expiration for key "${key}": ${error.message}`, core.ErrorCode.CACHE_OPERATION_FAILED, error);
|
|
1705
|
+
throw new CacheError(`Failed to set expiration for key "${key}": ${error.message}`, core$1.ErrorCode.CACHE_OPERATION_FAILED, error);
|
|
1701
1706
|
}
|
|
1702
1707
|
}
|
|
1703
1708
|
async scan(pattern, count = DEFAULT_BATCH_SIZE) {
|
|
@@ -1711,7 +1716,7 @@ var L2RedisStoreAdapter = class {
|
|
|
1711
1716
|
// Simplified: full scan completed
|
|
1712
1717
|
};
|
|
1713
1718
|
} catch (error) {
|
|
1714
|
-
throw new CacheError(`Failed to scan keys with pattern "${pattern}": ${error.message}`, core.ErrorCode.CACHE_OPERATION_FAILED, error);
|
|
1719
|
+
throw new CacheError(`Failed to scan keys with pattern "${pattern}": ${error.message}`, core$1.ErrorCode.CACHE_OPERATION_FAILED, error);
|
|
1715
1720
|
}
|
|
1716
1721
|
}
|
|
1717
1722
|
async getMany(keys) {
|
|
@@ -1747,7 +1752,7 @@ var L2RedisStoreAdapter = class {
|
|
|
1747
1752
|
})
|
|
1748
1753
|
);
|
|
1749
1754
|
} catch (error) {
|
|
1750
|
-
throw new CacheError(`Failed to set multiple cache entries: ${error.message}`, core.ErrorCode.CACHE_SET_FAILED, error);
|
|
1755
|
+
throw new CacheError(`Failed to set multiple cache entries: ${error.message}`, core$1.ErrorCode.CACHE_SET_FAILED, error);
|
|
1751
1756
|
}
|
|
1752
1757
|
}
|
|
1753
1758
|
buildKey(key) {
|
|
@@ -1800,13 +1805,13 @@ var L2RedisStoreAdapter = class {
|
|
|
1800
1805
|
const ttlSeconds = Math.max(1, Math.ceil(ttlMs / 1e3));
|
|
1801
1806
|
await this.driver.setex(fullKey, ttlSeconds, serialized);
|
|
1802
1807
|
} catch (error) {
|
|
1803
|
-
throw new CacheError(`Failed to set SWR entry for key "${key}": ${error.message}`, core.ErrorCode.CACHE_SET_FAILED, error);
|
|
1808
|
+
throw new CacheError(`Failed to set SWR entry for key "${key}": ${error.message}`, core$1.ErrorCode.CACHE_SET_FAILED, error);
|
|
1804
1809
|
}
|
|
1805
1810
|
}
|
|
1806
1811
|
};
|
|
1807
1812
|
L2RedisStoreAdapter = __decorateClass([
|
|
1808
1813
|
common.Injectable(),
|
|
1809
|
-
__decorateParam(0, common.Inject(core.REDIS_DRIVER)),
|
|
1814
|
+
__decorateParam(0, common.Inject(core$1.REDIS_DRIVER)),
|
|
1810
1815
|
__decorateParam(1, common.Inject(CACHE_PLUGIN_OPTIONS)),
|
|
1811
1816
|
__decorateParam(2, common.Inject(SERIALIZER))
|
|
1812
1817
|
], L2RedisStoreAdapter);
|
|
@@ -2201,7 +2206,7 @@ exports.EventInvalidationService = __decorateClass([
|
|
|
2201
2206
|
common.Injectable(),
|
|
2202
2207
|
__decorateParam(0, common.Inject(INVALIDATION_REGISTRY)),
|
|
2203
2208
|
__decorateParam(1, common.Inject(CACHE_SERVICE)),
|
|
2204
|
-
__decorateParam(2, common.Inject(core.REDIS_DRIVER)),
|
|
2209
|
+
__decorateParam(2, common.Inject(core$1.REDIS_DRIVER)),
|
|
2205
2210
|
__decorateParam(3, common.Inject(CACHE_PLUGIN_OPTIONS))
|
|
2206
2211
|
], exports.EventInvalidationService);
|
|
2207
2212
|
exports.InvalidationRegistryService = class InvalidationRegistryService {
|
|
@@ -2286,11 +2291,11 @@ var EventPattern = class _EventPattern {
|
|
|
2286
2291
|
*/
|
|
2287
2292
|
static create(pattern) {
|
|
2288
2293
|
if (!pattern || pattern.trim().length === 0) {
|
|
2289
|
-
throw new CacheError("Event pattern cannot be empty", core.ErrorCode.VALIDATION_FAILED);
|
|
2294
|
+
throw new CacheError("Event pattern cannot be empty", core$1.ErrorCode.VALIDATION_FAILED);
|
|
2290
2295
|
}
|
|
2291
2296
|
const normalized = pattern.trim();
|
|
2292
2297
|
if (!/^[a-z0-9*#._-]+$/i.test(normalized)) {
|
|
2293
|
-
throw new CacheError(`Invalid event pattern "${normalized}". Only alphanumeric, dots, dashes, underscores, *, and # are allowed`, core.ErrorCode.VALIDATION_FAILED);
|
|
2298
|
+
throw new CacheError(`Invalid event pattern "${normalized}". Only alphanumeric, dots, dashes, underscores, *, and # are allowed`, core$1.ErrorCode.VALIDATION_FAILED);
|
|
2294
2299
|
}
|
|
2295
2300
|
let regexStr = normalized.replace(/\./g, "\\.").replace(/\*/g, "[^.]+").replace(/#/g, ".*");
|
|
2296
2301
|
regexStr = regexStr.replace(/\\\.\.\*$/, "(?:\\..*)?");
|
|
@@ -2329,7 +2334,7 @@ var TagTemplate = class _TagTemplate {
|
|
|
2329
2334
|
*/
|
|
2330
2335
|
static create(template) {
|
|
2331
2336
|
if (!template || template.trim().length === 0) {
|
|
2332
|
-
throw new CacheError("Tag template cannot be empty", core.ErrorCode.VALIDATION_FAILED);
|
|
2337
|
+
throw new CacheError("Tag template cannot be empty", core$1.ErrorCode.VALIDATION_FAILED);
|
|
2333
2338
|
}
|
|
2334
2339
|
const normalized = template.trim();
|
|
2335
2340
|
const placeholders = [];
|
|
@@ -2713,7 +2718,7 @@ var StampedeProtectionService = class {
|
|
|
2713
2718
|
StampedeProtectionService = __decorateClass([
|
|
2714
2719
|
common.Injectable(),
|
|
2715
2720
|
__decorateParam(0, common.Inject(CACHE_PLUGIN_OPTIONS)),
|
|
2716
|
-
__decorateParam(1, common.Inject(core.REDIS_DRIVER))
|
|
2721
|
+
__decorateParam(1, common.Inject(core$1.REDIS_DRIVER))
|
|
2717
2722
|
], StampedeProtectionService);
|
|
2718
2723
|
var SwrManagerService = class {
|
|
2719
2724
|
constructor(options) {
|
|
@@ -2953,7 +2958,7 @@ var TagIndexRepository = class {
|
|
|
2953
2958
|
};
|
|
2954
2959
|
TagIndexRepository = __decorateClass([
|
|
2955
2960
|
common.Injectable(),
|
|
2956
|
-
__decorateParam(0, common.Inject(core.REDIS_DRIVER)),
|
|
2961
|
+
__decorateParam(0, common.Inject(core$1.REDIS_DRIVER)),
|
|
2957
2962
|
__decorateParam(1, common.Inject(CACHE_PLUGIN_OPTIONS)),
|
|
2958
2963
|
__decorateParam(2, common.Inject(LUA_SCRIPT_LOADER))
|
|
2959
2964
|
], TagIndexRepository);
|
|
@@ -3062,7 +3067,7 @@ var LuaScriptLoader = class {
|
|
|
3062
3067
|
};
|
|
3063
3068
|
LuaScriptLoader = __decorateClass([
|
|
3064
3069
|
common.Injectable(),
|
|
3065
|
-
__decorateParam(0, common.Inject(core.REDIS_DRIVER))
|
|
3070
|
+
__decorateParam(0, common.Inject(core$1.REDIS_DRIVER))
|
|
3066
3071
|
], LuaScriptLoader);
|
|
3067
3072
|
|
|
3068
3073
|
// src/cache.plugin.ts
|
|
@@ -3176,7 +3181,7 @@ var CachePlugin = class _CachePlugin {
|
|
|
3176
3181
|
// Cache warmup (runs on OnModuleInit if enabled)
|
|
3177
3182
|
WarmupService,
|
|
3178
3183
|
// Reflector is needed for decorator metadata
|
|
3179
|
-
core
|
|
3184
|
+
core.Reflector,
|
|
3180
3185
|
// Factory for registering static invalidation rules
|
|
3181
3186
|
{
|
|
3182
3187
|
provide: INVALIDATION_RULES_INIT,
|