@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
|
@@ -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
|
});
|
|
@@ -596,6 +596,51 @@ var DatabaseTransport = class {
|
|
|
596
596
|
// src/factories.mts
|
|
597
597
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
598
598
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
599
|
+
|
|
600
|
+
// src/cache/MultiCache.mts
|
|
601
|
+
var MultiCache = class {
|
|
602
|
+
constructor(caches) {
|
|
603
|
+
this.caches = caches;
|
|
604
|
+
}
|
|
605
|
+
static {
|
|
606
|
+
__name(this, "MultiCache");
|
|
607
|
+
}
|
|
608
|
+
async get(key) {
|
|
609
|
+
for (const cache2 of this.caches) {
|
|
610
|
+
const value = await cache2.get(key);
|
|
611
|
+
if (value !== void 0) {
|
|
612
|
+
return value;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return void 0;
|
|
616
|
+
}
|
|
617
|
+
async put(key, value, ttl) {
|
|
618
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
619
|
+
}
|
|
620
|
+
async delete(key) {
|
|
621
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
622
|
+
}
|
|
623
|
+
async has(key) {
|
|
624
|
+
for (const cache2 of this.caches) {
|
|
625
|
+
if (await cache2.has(key)) {
|
|
626
|
+
return true;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
return false;
|
|
630
|
+
}
|
|
631
|
+
async increment(key, amount) {
|
|
632
|
+
let rc = void 0;
|
|
633
|
+
for (const cache2 of this.caches) {
|
|
634
|
+
let rc2 = await cache2.increment(key, amount);
|
|
635
|
+
if (rc === void 0) {
|
|
636
|
+
rc = rc2;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
return rc;
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
// src/factories.mts
|
|
599
644
|
var FlexibleFactory = class {
|
|
600
645
|
static {
|
|
601
646
|
__name(this, "FlexibleFactory");
|
|
@@ -666,6 +711,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
666
711
|
CacheProviderFactory.register("file", (opt) => {
|
|
667
712
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
668
713
|
});
|
|
714
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
715
|
+
const caches = [];
|
|
716
|
+
for (const c of opt.caches) {
|
|
717
|
+
caches.push(cache(c));
|
|
718
|
+
}
|
|
719
|
+
return new MultiCache(caches);
|
|
720
|
+
});
|
|
669
721
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
670
722
|
return new import_neko_cache.DisabledCacheProvider();
|
|
671
723
|
});
|
|
@@ -594,6 +594,51 @@ var DatabaseTransport = class {
|
|
|
594
594
|
// src/factories.mts
|
|
595
595
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
596
596
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
597
|
+
|
|
598
|
+
// src/cache/MultiCache.mts
|
|
599
|
+
var MultiCache = class {
|
|
600
|
+
constructor(caches) {
|
|
601
|
+
this.caches = caches;
|
|
602
|
+
}
|
|
603
|
+
static {
|
|
604
|
+
__name(this, "MultiCache");
|
|
605
|
+
}
|
|
606
|
+
async get(key) {
|
|
607
|
+
for (const cache2 of this.caches) {
|
|
608
|
+
const value = await cache2.get(key);
|
|
609
|
+
if (value !== void 0) {
|
|
610
|
+
return value;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
return void 0;
|
|
614
|
+
}
|
|
615
|
+
async put(key, value, ttl) {
|
|
616
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
617
|
+
}
|
|
618
|
+
async delete(key) {
|
|
619
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
620
|
+
}
|
|
621
|
+
async has(key) {
|
|
622
|
+
for (const cache2 of this.caches) {
|
|
623
|
+
if (await cache2.has(key)) {
|
|
624
|
+
return true;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
return false;
|
|
628
|
+
}
|
|
629
|
+
async increment(key, amount) {
|
|
630
|
+
let rc = void 0;
|
|
631
|
+
for (const cache2 of this.caches) {
|
|
632
|
+
let rc2 = await cache2.increment(key, amount);
|
|
633
|
+
if (rc === void 0) {
|
|
634
|
+
rc = rc2;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
return rc;
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
// src/factories.mts
|
|
597
642
|
var FlexibleFactory = class {
|
|
598
643
|
static {
|
|
599
644
|
__name(this, "FlexibleFactory");
|
|
@@ -664,6 +709,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
664
709
|
CacheProviderFactory.register("file", (opt) => {
|
|
665
710
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
666
711
|
});
|
|
712
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
713
|
+
const caches = [];
|
|
714
|
+
for (const c of opt.caches) {
|
|
715
|
+
caches.push(cache(c));
|
|
716
|
+
}
|
|
717
|
+
return new MultiCache(caches);
|
|
718
|
+
});
|
|
667
719
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
668
720
|
return new import_neko_cache.DisabledCacheProvider();
|
|
669
721
|
});
|
|
@@ -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
|
});
|
|
@@ -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
|
});
|
|
@@ -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
|
});
|
|
@@ -1756,6 +1756,51 @@ var DatabaseTransport = class {
|
|
|
1756
1756
|
// src/factories.mts
|
|
1757
1757
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
1758
1758
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
1759
|
+
|
|
1760
|
+
// src/cache/MultiCache.mts
|
|
1761
|
+
var MultiCache = class {
|
|
1762
|
+
constructor(caches) {
|
|
1763
|
+
this.caches = caches;
|
|
1764
|
+
}
|
|
1765
|
+
static {
|
|
1766
|
+
__name(this, "MultiCache");
|
|
1767
|
+
}
|
|
1768
|
+
async get(key) {
|
|
1769
|
+
for (const cache2 of this.caches) {
|
|
1770
|
+
const value = await cache2.get(key);
|
|
1771
|
+
if (value !== void 0) {
|
|
1772
|
+
return value;
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
return void 0;
|
|
1776
|
+
}
|
|
1777
|
+
async put(key, value, ttl) {
|
|
1778
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
1779
|
+
}
|
|
1780
|
+
async delete(key) {
|
|
1781
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
1782
|
+
}
|
|
1783
|
+
async has(key) {
|
|
1784
|
+
for (const cache2 of this.caches) {
|
|
1785
|
+
if (await cache2.has(key)) {
|
|
1786
|
+
return true;
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
return false;
|
|
1790
|
+
}
|
|
1791
|
+
async increment(key, amount) {
|
|
1792
|
+
let rc = void 0;
|
|
1793
|
+
for (const cache2 of this.caches) {
|
|
1794
|
+
let rc2 = await cache2.increment(key, amount);
|
|
1795
|
+
if (rc === void 0) {
|
|
1796
|
+
rc = rc2;
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
return rc;
|
|
1800
|
+
}
|
|
1801
|
+
};
|
|
1802
|
+
|
|
1803
|
+
// src/factories.mts
|
|
1759
1804
|
var FlexibleFactory = class {
|
|
1760
1805
|
static {
|
|
1761
1806
|
__name(this, "FlexibleFactory");
|
|
@@ -1826,6 +1871,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
1826
1871
|
CacheProviderFactory.register("file", (opt) => {
|
|
1827
1872
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
1828
1873
|
});
|
|
1874
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
1875
|
+
const caches = [];
|
|
1876
|
+
for (const c of opt.caches) {
|
|
1877
|
+
caches.push(cache(c));
|
|
1878
|
+
}
|
|
1879
|
+
return new MultiCache(caches);
|
|
1880
|
+
});
|
|
1829
1881
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
1830
1882
|
return new import_neko_cache.DisabledCacheProvider();
|
|
1831
1883
|
});
|
|
@@ -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
|
});
|
|
@@ -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
|
});
|
|
@@ -1747,6 +1747,51 @@ var DatabaseTransport = class {
|
|
|
1747
1747
|
// src/factories.mts
|
|
1748
1748
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
1749
1749
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
1750
|
+
|
|
1751
|
+
// src/cache/MultiCache.mts
|
|
1752
|
+
var MultiCache = class {
|
|
1753
|
+
constructor(caches) {
|
|
1754
|
+
this.caches = caches;
|
|
1755
|
+
}
|
|
1756
|
+
static {
|
|
1757
|
+
__name(this, "MultiCache");
|
|
1758
|
+
}
|
|
1759
|
+
async get(key) {
|
|
1760
|
+
for (const cache2 of this.caches) {
|
|
1761
|
+
const value = await cache2.get(key);
|
|
1762
|
+
if (value !== void 0) {
|
|
1763
|
+
return value;
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
return void 0;
|
|
1767
|
+
}
|
|
1768
|
+
async put(key, value, ttl) {
|
|
1769
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
1770
|
+
}
|
|
1771
|
+
async delete(key) {
|
|
1772
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
1773
|
+
}
|
|
1774
|
+
async has(key) {
|
|
1775
|
+
for (const cache2 of this.caches) {
|
|
1776
|
+
if (await cache2.has(key)) {
|
|
1777
|
+
return true;
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
return false;
|
|
1781
|
+
}
|
|
1782
|
+
async increment(key, amount) {
|
|
1783
|
+
let rc = void 0;
|
|
1784
|
+
for (const cache2 of this.caches) {
|
|
1785
|
+
let rc2 = await cache2.increment(key, amount);
|
|
1786
|
+
if (rc === void 0) {
|
|
1787
|
+
rc = rc2;
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
return rc;
|
|
1791
|
+
}
|
|
1792
|
+
};
|
|
1793
|
+
|
|
1794
|
+
// src/factories.mts
|
|
1750
1795
|
var FlexibleFactory = class {
|
|
1751
1796
|
static {
|
|
1752
1797
|
__name(this, "FlexibleFactory");
|
|
@@ -1817,6 +1862,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
1817
1862
|
CacheProviderFactory.register("file", (opt) => {
|
|
1818
1863
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
1819
1864
|
});
|
|
1865
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
1866
|
+
const caches = [];
|
|
1867
|
+
for (const c of opt.caches) {
|
|
1868
|
+
caches.push(cache(c));
|
|
1869
|
+
}
|
|
1870
|
+
return new MultiCache(caches);
|
|
1871
|
+
});
|
|
1820
1872
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
1821
1873
|
return new import_neko_cache.DisabledCacheProvider();
|
|
1822
1874
|
});
|