@devbro/pashmak 0.1.56 → 0.1.57
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/cjs/app/console/DefaultCommand.js +52 -0
- package/dist/cjs/app/console/KeyGenerateCommand.js +52 -0
- package/dist/cjs/app/console/StartCommand.js +52 -0
- package/dist/cjs/app/console/generate/GenerateApiDocsCommand.js +52 -0
- package/dist/cjs/app/console/generate/GenerateControllerCommand.js +52 -0
- package/dist/cjs/app/console/generate/index.js +52 -0
- package/dist/cjs/app/console/index.js +52 -0
- package/dist/cjs/app/console/migrate/GenerateMigrateCommand.js +52 -0
- package/dist/cjs/app/console/migrate/MigrateCommand.js +52 -0
- package/dist/cjs/app/console/migrate/MigrateRollbackCommand.js +52 -0
- package/dist/cjs/app/console/migrate/index.js +52 -0
- package/dist/cjs/app/console/queue/GenerateQueueMigrateCommand.js +52 -0
- package/dist/cjs/cache/MultiCache.js +71 -0
- package/dist/cjs/{cache.js → cache/cache.js} +54 -2
- package/dist/cjs/facades.js +52 -0
- package/dist/cjs/factories.js +52 -0
- package/dist/cjs/http.js +52 -0
- package/dist/cjs/index.js +52 -0
- package/dist/cjs/middlewares.js +52 -0
- package/dist/cjs/queue.js +52 -0
- package/dist/esm/cache/MultiCache.d.mts +14 -0
- package/dist/esm/cache/MultiCache.mjs +47 -0
- package/dist/esm/cache/MultiCache.mjs.map +1 -0
- package/dist/esm/{cache.mjs → cache/cache.mjs} +1 -1
- package/dist/esm/cache/cache.mjs.map +1 -0
- package/dist/esm/factories.mjs +9 -0
- package/dist/esm/factories.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/esm/cache.mjs.map +0 -1
- /package/dist/esm/{cache.d.mts → cache/cache.d.mts} +0 -0
|
@@ -1749,6 +1749,51 @@ var DatabaseTransport = class {
|
|
|
1749
1749
|
// src/factories.mts
|
|
1750
1750
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
1751
1751
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
1752
|
+
|
|
1753
|
+
// src/cache/MultiCache.mts
|
|
1754
|
+
var MultiCache = class {
|
|
1755
|
+
constructor(caches) {
|
|
1756
|
+
this.caches = caches;
|
|
1757
|
+
}
|
|
1758
|
+
static {
|
|
1759
|
+
__name(this, "MultiCache");
|
|
1760
|
+
}
|
|
1761
|
+
async get(key) {
|
|
1762
|
+
for (const cache2 of this.caches) {
|
|
1763
|
+
const value = await cache2.get(key);
|
|
1764
|
+
if (value !== void 0) {
|
|
1765
|
+
return value;
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
return void 0;
|
|
1769
|
+
}
|
|
1770
|
+
async put(key, value, ttl) {
|
|
1771
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
1772
|
+
}
|
|
1773
|
+
async delete(key) {
|
|
1774
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
1775
|
+
}
|
|
1776
|
+
async has(key) {
|
|
1777
|
+
for (const cache2 of this.caches) {
|
|
1778
|
+
if (await cache2.has(key)) {
|
|
1779
|
+
return true;
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
return false;
|
|
1783
|
+
}
|
|
1784
|
+
async increment(key, amount) {
|
|
1785
|
+
let rc = void 0;
|
|
1786
|
+
for (const cache2 of this.caches) {
|
|
1787
|
+
let rc2 = await cache2.increment(key, amount);
|
|
1788
|
+
if (rc === void 0) {
|
|
1789
|
+
rc = rc2;
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
return rc;
|
|
1793
|
+
}
|
|
1794
|
+
};
|
|
1795
|
+
|
|
1796
|
+
// src/factories.mts
|
|
1752
1797
|
var FlexibleFactory = class {
|
|
1753
1798
|
static {
|
|
1754
1799
|
__name(this, "FlexibleFactory");
|
|
@@ -1819,6 +1864,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
1819
1864
|
CacheProviderFactory.register("file", (opt) => {
|
|
1820
1865
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
1821
1866
|
});
|
|
1867
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
1868
|
+
const caches = [];
|
|
1869
|
+
for (const c of opt.caches) {
|
|
1870
|
+
caches.push(cache(c));
|
|
1871
|
+
}
|
|
1872
|
+
return new MultiCache(caches);
|
|
1873
|
+
});
|
|
1822
1874
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
1823
1875
|
return new import_neko_cache.DisabledCacheProvider();
|
|
1824
1876
|
});
|
|
@@ -592,6 +592,51 @@ var DatabaseTransport = class {
|
|
|
592
592
|
// src/factories.mts
|
|
593
593
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
594
594
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
595
|
+
|
|
596
|
+
// src/cache/MultiCache.mts
|
|
597
|
+
var MultiCache = class {
|
|
598
|
+
constructor(caches) {
|
|
599
|
+
this.caches = caches;
|
|
600
|
+
}
|
|
601
|
+
static {
|
|
602
|
+
__name(this, "MultiCache");
|
|
603
|
+
}
|
|
604
|
+
async get(key) {
|
|
605
|
+
for (const cache2 of this.caches) {
|
|
606
|
+
const value = await cache2.get(key);
|
|
607
|
+
if (value !== void 0) {
|
|
608
|
+
return value;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
return void 0;
|
|
612
|
+
}
|
|
613
|
+
async put(key, value, ttl) {
|
|
614
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
615
|
+
}
|
|
616
|
+
async delete(key) {
|
|
617
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
618
|
+
}
|
|
619
|
+
async has(key) {
|
|
620
|
+
for (const cache2 of this.caches) {
|
|
621
|
+
if (await cache2.has(key)) {
|
|
622
|
+
return true;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
return false;
|
|
626
|
+
}
|
|
627
|
+
async increment(key, amount) {
|
|
628
|
+
let rc = void 0;
|
|
629
|
+
for (const cache2 of this.caches) {
|
|
630
|
+
let rc2 = await cache2.increment(key, amount);
|
|
631
|
+
if (rc === void 0) {
|
|
632
|
+
rc = rc2;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
return rc;
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
// src/factories.mts
|
|
595
640
|
var FlexibleFactory = class {
|
|
596
641
|
static {
|
|
597
642
|
__name(this, "FlexibleFactory");
|
|
@@ -662,6 +707,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
662
707
|
CacheProviderFactory.register("file", (opt) => {
|
|
663
708
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
664
709
|
});
|
|
710
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
711
|
+
const caches = [];
|
|
712
|
+
for (const c of opt.caches) {
|
|
713
|
+
caches.push(cache(c));
|
|
714
|
+
}
|
|
715
|
+
return new MultiCache(caches);
|
|
716
|
+
});
|
|
665
717
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
666
718
|
return new import_neko_cache.DisabledCacheProvider();
|
|
667
719
|
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/cache/MultiCache.mts
|
|
22
|
+
var MultiCache_exports = {};
|
|
23
|
+
__export(MultiCache_exports, {
|
|
24
|
+
MultiCache: () => MultiCache
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(MultiCache_exports);
|
|
27
|
+
var MultiCache = class {
|
|
28
|
+
constructor(caches) {
|
|
29
|
+
this.caches = caches;
|
|
30
|
+
}
|
|
31
|
+
static {
|
|
32
|
+
__name(this, "MultiCache");
|
|
33
|
+
}
|
|
34
|
+
async get(key) {
|
|
35
|
+
for (const cache of this.caches) {
|
|
36
|
+
const value = await cache.get(key);
|
|
37
|
+
if (value !== void 0) {
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return void 0;
|
|
42
|
+
}
|
|
43
|
+
async put(key, value, ttl) {
|
|
44
|
+
await Promise.all(this.caches.map((cache) => cache.put(key, value, ttl)));
|
|
45
|
+
}
|
|
46
|
+
async delete(key) {
|
|
47
|
+
await Promise.all(this.caches.map((cache) => cache.delete(key)));
|
|
48
|
+
}
|
|
49
|
+
async has(key) {
|
|
50
|
+
for (const cache of this.caches) {
|
|
51
|
+
if (await cache.has(key)) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
async increment(key, amount) {
|
|
58
|
+
let rc = void 0;
|
|
59
|
+
for (const cache of this.caches) {
|
|
60
|
+
let rc2 = await cache.increment(key, amount);
|
|
61
|
+
if (rc === void 0) {
|
|
62
|
+
rc = rc2;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return rc;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
MultiCache
|
|
71
|
+
});
|
|
@@ -29,7 +29,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
));
|
|
30
30
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
31
|
|
|
32
|
-
// src/cache.mts
|
|
32
|
+
// src/cache/cache.mts
|
|
33
33
|
var cache_exports = {};
|
|
34
34
|
__export(cache_exports, {
|
|
35
35
|
cacheQuery: () => cacheQuery
|
|
@@ -593,6 +593,51 @@ var DatabaseTransport = class {
|
|
|
593
593
|
// src/factories.mts
|
|
594
594
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
595
595
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
596
|
+
|
|
597
|
+
// src/cache/MultiCache.mts
|
|
598
|
+
var MultiCache = class {
|
|
599
|
+
constructor(caches) {
|
|
600
|
+
this.caches = caches;
|
|
601
|
+
}
|
|
602
|
+
static {
|
|
603
|
+
__name(this, "MultiCache");
|
|
604
|
+
}
|
|
605
|
+
async get(key) {
|
|
606
|
+
for (const cache2 of this.caches) {
|
|
607
|
+
const value = await cache2.get(key);
|
|
608
|
+
if (value !== void 0) {
|
|
609
|
+
return value;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
return void 0;
|
|
613
|
+
}
|
|
614
|
+
async put(key, value, ttl) {
|
|
615
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
616
|
+
}
|
|
617
|
+
async delete(key) {
|
|
618
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
619
|
+
}
|
|
620
|
+
async has(key) {
|
|
621
|
+
for (const cache2 of this.caches) {
|
|
622
|
+
if (await cache2.has(key)) {
|
|
623
|
+
return true;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
return false;
|
|
627
|
+
}
|
|
628
|
+
async increment(key, amount) {
|
|
629
|
+
let rc = void 0;
|
|
630
|
+
for (const cache2 of this.caches) {
|
|
631
|
+
let rc2 = await cache2.increment(key, amount);
|
|
632
|
+
if (rc === void 0) {
|
|
633
|
+
rc = rc2;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
return rc;
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
|
|
640
|
+
// src/factories.mts
|
|
596
641
|
var FlexibleFactory = class {
|
|
597
642
|
static {
|
|
598
643
|
__name(this, "FlexibleFactory");
|
|
@@ -663,6 +708,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
663
708
|
CacheProviderFactory.register("file", (opt) => {
|
|
664
709
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
665
710
|
});
|
|
711
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
712
|
+
const caches = [];
|
|
713
|
+
for (const c of opt.caches) {
|
|
714
|
+
caches.push(cache(c));
|
|
715
|
+
}
|
|
716
|
+
return new MultiCache(caches);
|
|
717
|
+
});
|
|
666
718
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
667
719
|
return new import_neko_cache.DisabledCacheProvider();
|
|
668
720
|
});
|
|
@@ -803,7 +855,7 @@ var cache = wrapSingletonWithAccessors(
|
|
|
803
855
|
})
|
|
804
856
|
);
|
|
805
857
|
|
|
806
|
-
// src/cache.mts
|
|
858
|
+
// src/cache/cache.mts
|
|
807
859
|
async function cacheQuery(q, options = {}) {
|
|
808
860
|
options.ttl = options.ttl ?? 3600;
|
|
809
861
|
options.cache_label = options.cache_label ?? "default";
|
package/dist/cjs/facades.js
CHANGED
|
@@ -601,6 +601,51 @@ var DatabaseTransport = class {
|
|
|
601
601
|
// src/factories.mts
|
|
602
602
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
603
603
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
604
|
+
|
|
605
|
+
// src/cache/MultiCache.mts
|
|
606
|
+
var MultiCache = class {
|
|
607
|
+
constructor(caches) {
|
|
608
|
+
this.caches = caches;
|
|
609
|
+
}
|
|
610
|
+
static {
|
|
611
|
+
__name(this, "MultiCache");
|
|
612
|
+
}
|
|
613
|
+
async get(key) {
|
|
614
|
+
for (const cache2 of this.caches) {
|
|
615
|
+
const value = await cache2.get(key);
|
|
616
|
+
if (value !== void 0) {
|
|
617
|
+
return value;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return void 0;
|
|
621
|
+
}
|
|
622
|
+
async put(key, value, ttl) {
|
|
623
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
624
|
+
}
|
|
625
|
+
async delete(key) {
|
|
626
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
627
|
+
}
|
|
628
|
+
async has(key) {
|
|
629
|
+
for (const cache2 of this.caches) {
|
|
630
|
+
if (await cache2.has(key)) {
|
|
631
|
+
return true;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return false;
|
|
635
|
+
}
|
|
636
|
+
async increment(key, amount) {
|
|
637
|
+
let rc = void 0;
|
|
638
|
+
for (const cache2 of this.caches) {
|
|
639
|
+
let rc2 = await cache2.increment(key, amount);
|
|
640
|
+
if (rc === void 0) {
|
|
641
|
+
rc = rc2;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return rc;
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
// src/factories.mts
|
|
604
649
|
var FlexibleFactory = class {
|
|
605
650
|
static {
|
|
606
651
|
__name(this, "FlexibleFactory");
|
|
@@ -671,6 +716,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
671
716
|
CacheProviderFactory.register("file", (opt) => {
|
|
672
717
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
673
718
|
});
|
|
719
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
720
|
+
const caches = [];
|
|
721
|
+
for (const c of opt.caches) {
|
|
722
|
+
caches.push(cache(c));
|
|
723
|
+
}
|
|
724
|
+
return new MultiCache(caches);
|
|
725
|
+
});
|
|
674
726
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
675
727
|
return new import_neko_cache.DisabledCacheProvider();
|
|
676
728
|
});
|
package/dist/cjs/factories.js
CHANGED
|
@@ -709,6 +709,51 @@ var DatabaseTransport = class {
|
|
|
709
709
|
// src/factories.mts
|
|
710
710
|
var import_neko_cache2 = require("@devbro/neko-cache");
|
|
711
711
|
var import_neko_storage2 = require("@devbro/neko-storage");
|
|
712
|
+
|
|
713
|
+
// src/cache/MultiCache.mts
|
|
714
|
+
var MultiCache = class {
|
|
715
|
+
constructor(caches) {
|
|
716
|
+
this.caches = caches;
|
|
717
|
+
}
|
|
718
|
+
static {
|
|
719
|
+
__name(this, "MultiCache");
|
|
720
|
+
}
|
|
721
|
+
async get(key) {
|
|
722
|
+
for (const cache2 of this.caches) {
|
|
723
|
+
const value = await cache2.get(key);
|
|
724
|
+
if (value !== void 0) {
|
|
725
|
+
return value;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
return void 0;
|
|
729
|
+
}
|
|
730
|
+
async put(key, value, ttl) {
|
|
731
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
732
|
+
}
|
|
733
|
+
async delete(key) {
|
|
734
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
735
|
+
}
|
|
736
|
+
async has(key) {
|
|
737
|
+
for (const cache2 of this.caches) {
|
|
738
|
+
if (await cache2.has(key)) {
|
|
739
|
+
return true;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
return false;
|
|
743
|
+
}
|
|
744
|
+
async increment(key, amount) {
|
|
745
|
+
let rc = void 0;
|
|
746
|
+
for (const cache2 of this.caches) {
|
|
747
|
+
let rc2 = await cache2.increment(key, amount);
|
|
748
|
+
if (rc === void 0) {
|
|
749
|
+
rc = rc2;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
return rc;
|
|
753
|
+
}
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
// src/factories.mts
|
|
712
757
|
var FlexibleFactory = class {
|
|
713
758
|
static {
|
|
714
759
|
__name(this, "FlexibleFactory");
|
|
@@ -779,6 +824,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
779
824
|
CacheProviderFactory.register("file", (opt) => {
|
|
780
825
|
return new import_neko_cache2.FileCacheProvider(opt);
|
|
781
826
|
});
|
|
827
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
828
|
+
const caches = [];
|
|
829
|
+
for (const c of opt.caches) {
|
|
830
|
+
caches.push(cache(c));
|
|
831
|
+
}
|
|
832
|
+
return new MultiCache(caches);
|
|
833
|
+
});
|
|
782
834
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
783
835
|
return new import_neko_cache2.DisabledCacheProvider();
|
|
784
836
|
});
|
package/dist/cjs/http.js
CHANGED
|
@@ -570,6 +570,51 @@ var DatabaseTransport = class {
|
|
|
570
570
|
// src/factories.mts
|
|
571
571
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
572
572
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
573
|
+
|
|
574
|
+
// src/cache/MultiCache.mts
|
|
575
|
+
var MultiCache = class {
|
|
576
|
+
constructor(caches) {
|
|
577
|
+
this.caches = caches;
|
|
578
|
+
}
|
|
579
|
+
static {
|
|
580
|
+
__name(this, "MultiCache");
|
|
581
|
+
}
|
|
582
|
+
async get(key) {
|
|
583
|
+
for (const cache2 of this.caches) {
|
|
584
|
+
const value = await cache2.get(key);
|
|
585
|
+
if (value !== void 0) {
|
|
586
|
+
return value;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
return void 0;
|
|
590
|
+
}
|
|
591
|
+
async put(key, value, ttl) {
|
|
592
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
593
|
+
}
|
|
594
|
+
async delete(key) {
|
|
595
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
596
|
+
}
|
|
597
|
+
async has(key) {
|
|
598
|
+
for (const cache2 of this.caches) {
|
|
599
|
+
if (await cache2.has(key)) {
|
|
600
|
+
return true;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
return false;
|
|
604
|
+
}
|
|
605
|
+
async increment(key, amount) {
|
|
606
|
+
let rc = void 0;
|
|
607
|
+
for (const cache2 of this.caches) {
|
|
608
|
+
let rc2 = await cache2.increment(key, amount);
|
|
609
|
+
if (rc === void 0) {
|
|
610
|
+
rc = rc2;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
return rc;
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
// src/factories.mts
|
|
573
618
|
var FlexibleFactory = class {
|
|
574
619
|
static {
|
|
575
620
|
__name(this, "FlexibleFactory");
|
|
@@ -640,6 +685,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
640
685
|
CacheProviderFactory.register("file", (opt) => {
|
|
641
686
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
642
687
|
});
|
|
688
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
689
|
+
const caches = [];
|
|
690
|
+
for (const c of opt.caches) {
|
|
691
|
+
caches.push(cache(c));
|
|
692
|
+
}
|
|
693
|
+
return new MultiCache(caches);
|
|
694
|
+
});
|
|
643
695
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
644
696
|
return new import_neko_cache.DisabledCacheProvider();
|
|
645
697
|
});
|
package/dist/cjs/index.js
CHANGED
|
@@ -1739,6 +1739,51 @@ var DatabaseTransport = class {
|
|
|
1739
1739
|
// src/factories.mts
|
|
1740
1740
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
1741
1741
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
1742
|
+
|
|
1743
|
+
// src/cache/MultiCache.mts
|
|
1744
|
+
var MultiCache = class {
|
|
1745
|
+
constructor(caches) {
|
|
1746
|
+
this.caches = caches;
|
|
1747
|
+
}
|
|
1748
|
+
static {
|
|
1749
|
+
__name(this, "MultiCache");
|
|
1750
|
+
}
|
|
1751
|
+
async get(key) {
|
|
1752
|
+
for (const cache2 of this.caches) {
|
|
1753
|
+
const value = await cache2.get(key);
|
|
1754
|
+
if (value !== void 0) {
|
|
1755
|
+
return value;
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
return void 0;
|
|
1759
|
+
}
|
|
1760
|
+
async put(key, value, ttl) {
|
|
1761
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
1762
|
+
}
|
|
1763
|
+
async delete(key) {
|
|
1764
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
1765
|
+
}
|
|
1766
|
+
async has(key) {
|
|
1767
|
+
for (const cache2 of this.caches) {
|
|
1768
|
+
if (await cache2.has(key)) {
|
|
1769
|
+
return true;
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
return false;
|
|
1773
|
+
}
|
|
1774
|
+
async increment(key, amount) {
|
|
1775
|
+
let rc = void 0;
|
|
1776
|
+
for (const cache2 of this.caches) {
|
|
1777
|
+
let rc2 = await cache2.increment(key, amount);
|
|
1778
|
+
if (rc === void 0) {
|
|
1779
|
+
rc = rc2;
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
return rc;
|
|
1783
|
+
}
|
|
1784
|
+
};
|
|
1785
|
+
|
|
1786
|
+
// src/factories.mts
|
|
1742
1787
|
var FlexibleFactory = class {
|
|
1743
1788
|
static {
|
|
1744
1789
|
__name(this, "FlexibleFactory");
|
|
@@ -1809,6 +1854,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
1809
1854
|
CacheProviderFactory.register("file", (opt) => {
|
|
1810
1855
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
1811
1856
|
});
|
|
1857
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
1858
|
+
const caches = [];
|
|
1859
|
+
for (const c of opt.caches) {
|
|
1860
|
+
caches.push(cache(c));
|
|
1861
|
+
}
|
|
1862
|
+
return new MultiCache(caches);
|
|
1863
|
+
});
|
|
1812
1864
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
1813
1865
|
return new import_neko_cache.DisabledCacheProvider();
|
|
1814
1866
|
});
|
package/dist/cjs/middlewares.js
CHANGED
|
@@ -595,6 +595,51 @@ var DatabaseTransport = class {
|
|
|
595
595
|
// src/factories.mts
|
|
596
596
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
597
597
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
598
|
+
|
|
599
|
+
// src/cache/MultiCache.mts
|
|
600
|
+
var MultiCache = class {
|
|
601
|
+
constructor(caches) {
|
|
602
|
+
this.caches = caches;
|
|
603
|
+
}
|
|
604
|
+
static {
|
|
605
|
+
__name(this, "MultiCache");
|
|
606
|
+
}
|
|
607
|
+
async get(key) {
|
|
608
|
+
for (const cache2 of this.caches) {
|
|
609
|
+
const value = await cache2.get(key);
|
|
610
|
+
if (value !== void 0) {
|
|
611
|
+
return value;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
return void 0;
|
|
615
|
+
}
|
|
616
|
+
async put(key, value, ttl) {
|
|
617
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
618
|
+
}
|
|
619
|
+
async delete(key) {
|
|
620
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
621
|
+
}
|
|
622
|
+
async has(key) {
|
|
623
|
+
for (const cache2 of this.caches) {
|
|
624
|
+
if (await cache2.has(key)) {
|
|
625
|
+
return true;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
return false;
|
|
629
|
+
}
|
|
630
|
+
async increment(key, amount) {
|
|
631
|
+
let rc = void 0;
|
|
632
|
+
for (const cache2 of this.caches) {
|
|
633
|
+
let rc2 = await cache2.increment(key, amount);
|
|
634
|
+
if (rc === void 0) {
|
|
635
|
+
rc = rc2;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return rc;
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
// src/factories.mts
|
|
598
643
|
var FlexibleFactory = class {
|
|
599
644
|
static {
|
|
600
645
|
__name(this, "FlexibleFactory");
|
|
@@ -665,6 +710,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
665
710
|
CacheProviderFactory.register("file", (opt) => {
|
|
666
711
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
667
712
|
});
|
|
713
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
714
|
+
const caches = [];
|
|
715
|
+
for (const c of opt.caches) {
|
|
716
|
+
caches.push(cache(c));
|
|
717
|
+
}
|
|
718
|
+
return new MultiCache(caches);
|
|
719
|
+
});
|
|
668
720
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
669
721
|
return new import_neko_cache.DisabledCacheProvider();
|
|
670
722
|
});
|
package/dist/cjs/queue.js
CHANGED
|
@@ -490,6 +490,51 @@ var import_neko_mailer = require("@devbro/neko-mailer");
|
|
|
490
490
|
var import_neko_queue = require("@devbro/neko-queue");
|
|
491
491
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
492
492
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
493
|
+
|
|
494
|
+
// src/cache/MultiCache.mts
|
|
495
|
+
var MultiCache = class {
|
|
496
|
+
constructor(caches) {
|
|
497
|
+
this.caches = caches;
|
|
498
|
+
}
|
|
499
|
+
static {
|
|
500
|
+
__name(this, "MultiCache");
|
|
501
|
+
}
|
|
502
|
+
async get(key) {
|
|
503
|
+
for (const cache2 of this.caches) {
|
|
504
|
+
const value = await cache2.get(key);
|
|
505
|
+
if (value !== void 0) {
|
|
506
|
+
return value;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return void 0;
|
|
510
|
+
}
|
|
511
|
+
async put(key, value, ttl) {
|
|
512
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
513
|
+
}
|
|
514
|
+
async delete(key) {
|
|
515
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
516
|
+
}
|
|
517
|
+
async has(key) {
|
|
518
|
+
for (const cache2 of this.caches) {
|
|
519
|
+
if (await cache2.has(key)) {
|
|
520
|
+
return true;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
return false;
|
|
524
|
+
}
|
|
525
|
+
async increment(key, amount) {
|
|
526
|
+
let rc = void 0;
|
|
527
|
+
for (const cache2 of this.caches) {
|
|
528
|
+
let rc2 = await cache2.increment(key, amount);
|
|
529
|
+
if (rc === void 0) {
|
|
530
|
+
rc = rc2;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
return rc;
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
// src/factories.mts
|
|
493
538
|
var FlexibleFactory = class {
|
|
494
539
|
static {
|
|
495
540
|
__name(this, "FlexibleFactory");
|
|
@@ -560,6 +605,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
560
605
|
CacheProviderFactory.register("file", (opt) => {
|
|
561
606
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
562
607
|
});
|
|
608
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
609
|
+
const caches = [];
|
|
610
|
+
for (const c of opt.caches) {
|
|
611
|
+
caches.push(cache(c));
|
|
612
|
+
}
|
|
613
|
+
return new MultiCache(caches);
|
|
614
|
+
});
|
|
563
615
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
564
616
|
return new import_neko_cache.DisabledCacheProvider();
|
|
565
617
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { JSONValue, JSONObject } from '@devbro/neko-helper';
|
|
2
|
+
import { CacheProviderInterface } from '@devbro/neko-cache';
|
|
3
|
+
|
|
4
|
+
declare class MultiCache implements CacheProviderInterface {
|
|
5
|
+
private caches;
|
|
6
|
+
constructor(caches: CacheProviderInterface[]);
|
|
7
|
+
get(key: string): Promise<JSONValue | JSONObject | undefined>;
|
|
8
|
+
put(key: string, value: JSONObject | JSONValue, ttl?: number): Promise<void>;
|
|
9
|
+
delete(key: string): Promise<void>;
|
|
10
|
+
has(key: string): Promise<boolean>;
|
|
11
|
+
increment(key: string, amount?: number): Promise<number>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { MultiCache };
|