@daiso-tech/core 0.20.0 → 0.21.1
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/async/utilities/lazy-promise/lazy-promise.js +13 -7
- package/dist/cjs/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
- package/dist/cjs/cache/contracts/cache.errors.js +13 -0
- package/dist/cjs/cache/contracts/cache.errors.js.map +1 -1
- package/dist/cjs/cache/contracts/cache.events.js +17 -130
- package/dist/cjs/cache/contracts/cache.events.js.map +1 -1
- package/dist/cjs/cache/implementations/_shared/cache-adapter.test-suite.js +0 -19
- package/dist/cjs/cache/implementations/_shared/cache-adapter.test-suite.js.map +1 -1
- package/dist/cjs/cache/implementations/_shared/cache.test-suite.js +671 -0
- package/dist/cjs/cache/implementations/_shared/cache.test-suite.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js +0 -20
- package/dist/cjs/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +0 -3
- package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +0 -4
- package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +0 -23
- package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js +0 -3
- package/dist/cjs/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +0 -5
- package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +0 -3
- package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map +1 -1
- package/dist/cjs/cache/implementations/derivables/cache/cache-settings.js +0 -18
- package/dist/cjs/cache/implementations/derivables/cache/cache-settings.js.map +1 -1
- package/dist/cjs/cache/implementations/derivables/cache/cache.js +4 -69
- package/dist/cjs/cache/implementations/derivables/cache/cache.js.map +1 -1
- package/dist/cjs/cache/implementations/derivables/cache-factory/cache-factory.js +17 -13
- package/dist/cjs/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
- package/dist/cjs/event-bus/contracts/_shared.js +3 -2
- package/dist/cjs/event-bus/contracts/_shared.js.map +1 -1
- package/dist/cjs/event-bus/contracts/event-bus.errors.js +14 -0
- package/dist/cjs/event-bus/contracts/event-bus.errors.js.map +1 -1
- package/dist/cjs/event-bus/implementations/_shared/event-bus-adapter.test-suite.js +1 -12
- package/dist/cjs/event-bus/implementations/_shared/event-bus-adapter.test-suite.js.map +1 -1
- package/dist/cjs/event-bus/implementations/_shared/event-bus.test-suite.js +2 -24
- package/dist/cjs/event-bus/implementations/_shared/event-bus.test-suite.js.map +1 -1
- package/dist/cjs/event-bus/implementations/derivables/event-bus/event-bus-settings.js +0 -12
- package/dist/cjs/event-bus/implementations/derivables/event-bus/event-bus-settings.js.map +1 -1
- package/dist/cjs/event-bus/implementations/derivables/event-bus/event-bus.js +1 -29
- package/dist/cjs/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
- package/dist/cjs/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +17 -15
- package/dist/cjs/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
- package/dist/cjs/serde/implementations/no-op-serde/no-op-serde.js +3 -0
- package/dist/cjs/serde/implementations/no-op-serde/no-op-serde.js.map +1 -1
- package/dist/cjs/serde/implementations/super-json-serde/super-json-serde.js +15 -0
- package/dist/cjs/serde/implementations/super-json-serde/super-json-serde.js.map +1 -1
- package/dist/esm/async/utilities/lazy-promise/lazy-promise.js +13 -7
- package/dist/esm/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
- package/dist/esm/cache/contracts/cache.errors.js +12 -0
- package/dist/esm/cache/contracts/cache.errors.js.map +1 -1
- package/dist/esm/cache/contracts/cache.events.js +15 -129
- package/dist/esm/cache/contracts/cache.events.js.map +1 -1
- package/dist/esm/cache/implementations/_shared/cache-adapter.test-suite.js +0 -19
- package/dist/esm/cache/implementations/_shared/cache-adapter.test-suite.js.map +1 -1
- package/dist/esm/cache/implementations/_shared/cache.test-suite.js +672 -1
- package/dist/esm/cache/implementations/_shared/cache.test-suite.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js +0 -20
- package/dist/esm/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +0 -3
- package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +0 -4
- package/dist/esm/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +0 -23
- package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js +0 -3
- package/dist/esm/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +0 -5
- package/dist/esm/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +0 -3
- package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map +1 -1
- package/dist/esm/cache/implementations/derivables/cache/cache-settings.js +0 -18
- package/dist/esm/cache/implementations/derivables/cache/cache-settings.js.map +1 -1
- package/dist/esm/cache/implementations/derivables/cache/cache.js +5 -70
- package/dist/esm/cache/implementations/derivables/cache/cache.js.map +1 -1
- package/dist/esm/cache/implementations/derivables/cache-factory/cache-factory.js +17 -13
- package/dist/esm/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
- package/dist/esm/event-bus/contracts/_shared.js +3 -2
- package/dist/esm/event-bus/contracts/_shared.js.map +1 -1
- package/dist/esm/event-bus/contracts/event-bus.errors.js +13 -0
- package/dist/esm/event-bus/contracts/event-bus.errors.js.map +1 -1
- package/dist/esm/event-bus/implementations/_shared/event-bus-adapter.test-suite.js +1 -12
- package/dist/esm/event-bus/implementations/_shared/event-bus-adapter.test-suite.js.map +1 -1
- package/dist/esm/event-bus/implementations/_shared/event-bus.test-suite.js +2 -24
- package/dist/esm/event-bus/implementations/_shared/event-bus.test-suite.js.map +1 -1
- package/dist/esm/event-bus/implementations/derivables/event-bus/event-bus-settings.js +0 -12
- package/dist/esm/event-bus/implementations/derivables/event-bus/event-bus-settings.js.map +1 -1
- package/dist/esm/event-bus/implementations/derivables/event-bus/event-bus.js +2 -30
- package/dist/esm/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
- package/dist/esm/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +14 -12
- package/dist/esm/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
- package/dist/esm/serde/implementations/no-op-serde/no-op-serde.js +3 -0
- package/dist/esm/serde/implementations/no-op-serde/no-op-serde.js.map +1 -1
- package/dist/esm/serde/implementations/super-json-serde/super-json-serde.js +15 -0
- package/dist/esm/serde/implementations/super-json-serde/super-json-serde.js.map +1 -1
- package/dist/types/cache/contracts/cache-adapter.contract.d.ts +0 -4
- package/dist/types/cache/contracts/cache.errors.d.ts +7 -2
- package/dist/types/cache/contracts/cache.events.d.ts +22 -93
- package/dist/types/cache/implementations/_shared/cache.test-suite.d.ts +6 -10
- package/dist/types/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.d.ts +0 -1
- package/dist/types/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.d.ts +0 -1
- package/dist/types/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts +0 -1
- package/dist/types/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts +0 -1
- package/dist/types/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.d.ts +0 -1
- package/dist/types/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts +0 -1
- package/dist/types/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts +0 -1
- package/dist/types/cache/implementations/derivables/cache/cache-settings.d.ts +2 -29
- package/dist/types/cache/implementations/derivables/cache/cache.d.ts +5 -33
- package/dist/types/cache/implementations/derivables/cache-factory/cache-factory-settings.d.ts +1 -1
- package/dist/types/cache/implementations/derivables/cache-factory/cache-factory.d.ts +4 -5
- package/dist/types/event-bus/contracts/_shared.d.ts +3 -4
- package/dist/types/event-bus/contracts/event-bus-factory.contract.d.ts +4 -23
- package/dist/types/event-bus/contracts/event-bus.errors.d.ts +7 -2
- package/dist/types/event-bus/implementations/derivables/event-bus/event-bus-settings.d.ts +1 -19
- package/dist/types/event-bus/implementations/derivables/event-bus/event-bus.d.ts +16 -14
- package/dist/types/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +30 -5
- package/dist/types/serde/contracts/flexible-serde.contract.d.ts +3 -2
- package/dist/types/serde/implementations/no-op-serde/no-op-serde.d.ts +2 -1
- package/dist/types/serde/implementations/super-json-serde/super-json-serde.d.ts +2 -1
- package/package.json +1 -1
package/dist/esm/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { registerEventBusErrors, } from "../../../../event-bus/contracts/_module";
|
|
1
2
|
import { EventBus } from "../../../../event-bus/implementations/derivables/event-bus/event-bus";
|
|
2
3
|
import { DefaultAdapterNotDefinedError, UnregisteredAdapterError, } from "../../../../utilities/_module";
|
|
3
4
|
import { EventBusFactorySettingsBuilder, } from "../../../../event-bus/implementations/derivables/event-bus-factory/event-bus-factory-settings";
|
|
@@ -5,9 +6,8 @@ export class EventBusFactory {
|
|
|
5
6
|
static settings() {
|
|
6
7
|
return new EventBusFactorySettingsBuilder();
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
eventBusRecord = {};
|
|
9
10
|
serde;
|
|
10
|
-
adapters;
|
|
11
11
|
defaultAdapter;
|
|
12
12
|
retryAttempts;
|
|
13
13
|
backoffPolicy;
|
|
@@ -15,39 +15,41 @@ export class EventBusFactory {
|
|
|
15
15
|
timeout;
|
|
16
16
|
shouldRegisterErrors;
|
|
17
17
|
constructor(settings) {
|
|
18
|
-
const { shouldRegisterErrors, serde,
|
|
18
|
+
const { adapters, shouldRegisterErrors = true, serde, defaultAdapter, retryAttempts, backoffPolicy, retryPolicy, timeout, } = settings;
|
|
19
19
|
this.shouldRegisterErrors = shouldRegisterErrors;
|
|
20
20
|
this.serde = serde;
|
|
21
21
|
this.retryAttempts = retryAttempts;
|
|
22
22
|
this.backoffPolicy = backoffPolicy;
|
|
23
23
|
this.retryPolicy = retryPolicy;
|
|
24
24
|
this.timeout = timeout;
|
|
25
|
-
this.adapters = adapters;
|
|
26
25
|
this.defaultAdapter = defaultAdapter;
|
|
27
|
-
this.
|
|
26
|
+
this.eventBusRecord = this.init(adapters);
|
|
28
27
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
init(adapters) {
|
|
29
|
+
if (this.shouldRegisterErrors) {
|
|
30
|
+
registerEventBusErrors(this.serde);
|
|
31
|
+
}
|
|
32
|
+
const eventBusRecord = {};
|
|
33
|
+
for (const key in adapters) {
|
|
34
|
+
const { [key]: adapter } = adapters;
|
|
32
35
|
if (adapter === undefined) {
|
|
33
36
|
continue;
|
|
34
37
|
}
|
|
35
|
-
|
|
36
|
-
serde: this.serde,
|
|
38
|
+
eventBusRecord[key] = new EventBus({
|
|
37
39
|
adapter,
|
|
38
40
|
retryAttempts: this.retryAttempts,
|
|
39
41
|
backoffPolicy: this.backoffPolicy,
|
|
40
42
|
retryPolicy: this.retryPolicy,
|
|
41
43
|
timeout: this.timeout,
|
|
42
|
-
shouldRegisterErrors: this.shouldRegisterErrors,
|
|
43
44
|
});
|
|
44
45
|
}
|
|
46
|
+
return eventBusRecord;
|
|
45
47
|
}
|
|
46
48
|
use(adapterName = this.defaultAdapter) {
|
|
47
49
|
if (adapterName === undefined) {
|
|
48
50
|
throw new DefaultAdapterNotDefinedError(EventBusFactory.name);
|
|
49
51
|
}
|
|
50
|
-
const eventBus = this.
|
|
52
|
+
const eventBus = this.eventBusRecord[adapterName];
|
|
51
53
|
if (eventBus === undefined) {
|
|
52
54
|
throw new UnregisteredAdapterError(adapterName);
|
|
53
55
|
}
|
package/dist/esm/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-bus-factory.js","sourceRoot":"","sources":["../../../../../../src/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"event-bus-factory.js","sourceRoot":"","sources":["../../../../../../src/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.ts"],"names":[],"mappings":"AAKA,OAAO,EAIH,sBAAsB,GACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,4DAA4D,CAAC;AAEtF,OAAO,EACH,6BAA6B,EAC7B,wB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,EAAE,CAAC;gBACxB,SAAS;YACb,CAAC;YACD,cAAc,CAAC,GAAG,CAAC,GAAG,IAAI,QAAQ,CAAC;gBAC/B,OAAO;gBACP,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,OAAO,EAAE,IAAI,CAAC,OAAO;aACxB,CAAC,CAAC;QACP,CAAC;QACD,OAAO,cAAc,CAAC;IAC1B,CAAC;IAED,GAAG,CACC,cAAqC,IAAI,CAAC,cAAc;QAExD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,6BAA6B,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAClE,CAAC;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QAClD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,IAAI,wBAAwB,CAAC,WAAW,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-op-serde.js","sourceRoot":"","sources":["../../../../../src/serde/implementations/no-op-serde/no-op-serde.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"no-op-serde.js","sourceRoot":"","sources":["../../../../../src/serde/implementations/no-op-serde/no-op-serde.ts"],"names":[],"mappings":"AAgBA,MAAM,OAAO,SAAS;IAGlB,aAAa,CACT,WAA4C;QAE5C,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,SAAS,CAAS,KAAa;QAE3B,OAAO,KAAY,CAAC;IACxB,CAAC;IAED,WAAW,CAAS,eAAiC;QAEjD,OAAO,eAAsB,CAAC;IAClC,CAAC;IAED,aAAa,CACT,MAAmD;QAEnD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,cAAc,CACV,YAAuE;QAEvE,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getConstructorName } from "../../../utilities/_module";
|
|
2
2
|
import { DeserializationError, SerializationError, } from "../../../serde/contracts/serde.errors";
|
|
3
3
|
import { SuperJSON } from "superjson-cjs";
|
|
4
|
+
import { BaseEvent } from "../../../_module";
|
|
4
5
|
export class SuperJsonSerde {
|
|
5
6
|
superJson = new SuperJSON();
|
|
6
7
|
constructor() {
|
|
@@ -200,6 +201,20 @@ export class SuperJsonSerde {
|
|
|
200
201
|
name: class_.name,
|
|
201
202
|
});
|
|
202
203
|
}
|
|
204
|
+
registerEvent(eventClass) {
|
|
205
|
+
return this.registerCustom({
|
|
206
|
+
name: eventClass.name,
|
|
207
|
+
isApplicable(value) {
|
|
208
|
+
return value instanceof BaseEvent;
|
|
209
|
+
},
|
|
210
|
+
serialize(deserializedValue) {
|
|
211
|
+
return deserializedValue.fields;
|
|
212
|
+
},
|
|
213
|
+
deserialize(serializedValue) {
|
|
214
|
+
return new eventClass(serializedValue);
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
}
|
|
203
218
|
serialize(value) {
|
|
204
219
|
try {
|
|
205
220
|
return this.superJson.stringify(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"super-json-serde.js","sourceRoot":"","sources":["../../../../../src/serde/implementations/super-json-serde/super-json-serde.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"super-json-serde.js","sourceRoot":"","sources":["../../../../../src/serde/implementations/super-json-serde/super-json-serde.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAQzD,OAAO,EACH,oBAAoB,EACpB,kBAAkB,GACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,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,SAAS,CAAC,iBAAqC;gBAC3C,OAAO,iBAAiB,CAAC,MAAM,CAAC;YACpC,CAAC;YACD,WAAW,CAAC,eAAwB;gBAChC,OAAO,IAAI,UAAU,CAAC,eAAe,CAAC,CAAC;YAC3C,CAAC;SACJ,CAAC,CAAC;IACP,CAAC;IAED,SAAS,CAAS,KAAa;QAC3B,IAAI,CAAC;YACD,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACtB,MAAM,IAAI,kBAAkB,CACxB,wBAAwB,MAAM,CAAC,KAAK,CAAC,WAAW,EAChD,KAAK,CACR,CAAC;QACN,CAAC;IACL,CAAC;IAED,WAAW,CAAS,KAAa;QAC7B,IAAI,CAAC;YACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACtB,MAAM,IAAI,oBAAoB,CAC1B,0BAA0B,MAAM,CAAC,KAAK,CAAC,WAAW,EAClD,KAAK,CACR,CAAC;QACN,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -8,10 +8,6 @@ import type { TimeSpan } from "../../utilities/_module";
|
|
|
8
8
|
* @group Contracts
|
|
9
9
|
*/
|
|
10
10
|
export type ICacheAdapter<TType = unknown> = {
|
|
11
|
-
/**
|
|
12
|
-
* The <i>exists</i> returns true if the <i>key</i> if exists otherwise false will be returned.
|
|
13
|
-
*/
|
|
14
|
-
exists(key: string): PromiseLike<boolean>;
|
|
15
11
|
/**
|
|
16
12
|
* The <i>get</i> returns the <i>key</i> value if found otherwise null will be returned.
|
|
17
13
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Cache
|
|
3
3
|
*/
|
|
4
|
-
import type { ISerializable } from "../../serde/contracts/_module";
|
|
5
|
-
import type { ISerializedError } from "../../utilities/_module";
|
|
4
|
+
import type { IFlexibleSerde, ISerializable } from "../../serde/contracts/_module";
|
|
5
|
+
import type { ISerializedError, OneOrMore } from "../../utilities/_module";
|
|
6
6
|
/**
|
|
7
7
|
* @group Errors
|
|
8
8
|
*/
|
|
@@ -32,3 +32,8 @@ export declare class KeyNotFoundCacheError extends CacheError implements ISerial
|
|
|
32
32
|
static deserialize(deserializedValue: ISerializedError): CacheError;
|
|
33
33
|
constructor(message: string, cause?: unknown);
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* The <i>registerCacheErrors</i> function registers all <i>{@link IGroupableCache}</i> related errors with <i>IFlexibleSerde</i>, ensuring they will properly be serialized and deserialized.
|
|
37
|
+
* @group Errors
|
|
38
|
+
*/
|
|
39
|
+
export declare function registerCacheErrors(serde: OneOrMore<IFlexibleSerde>): void;
|
|
@@ -2,154 +2,83 @@
|
|
|
2
2
|
* @module Cache
|
|
3
3
|
*/
|
|
4
4
|
import { BaseEvent } from "../../event-bus/contracts/_module";
|
|
5
|
-
import type {
|
|
5
|
+
import type { IFlexibleSerde } from "../../serde/contracts/_module";
|
|
6
|
+
import type { OneOrMore, TimeSpan } from "../../utilities/_module";
|
|
6
7
|
/**
|
|
7
8
|
* @group Events
|
|
8
9
|
*/
|
|
9
|
-
export
|
|
10
|
+
export declare class KeyFoundCacheEvent<TType = unknown> extends BaseEvent<{
|
|
10
11
|
group: string;
|
|
11
12
|
key: string;
|
|
12
13
|
value: TType;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* @group Events
|
|
16
|
-
*/
|
|
17
|
-
export declare class KeyFoundCacheEvent<TType = unknown> extends BaseEvent<KeyFoundCacheEventFields<TType>> {
|
|
18
|
-
group: string;
|
|
19
|
-
key: string;
|
|
20
|
-
value: TType;
|
|
21
|
-
static deserialize<TType>(serializedEvent: KeyFoundCacheEventFields<TType>): KeyFoundCacheEvent<TType>;
|
|
22
|
-
constructor(fields: KeyFoundCacheEventFields<TType>);
|
|
23
|
-
serialize(): KeyFoundCacheEventFields<TType>;
|
|
14
|
+
}> {
|
|
24
15
|
}
|
|
25
16
|
/**
|
|
26
17
|
* @group Events
|
|
27
18
|
*/
|
|
28
|
-
export
|
|
19
|
+
export declare class KeyNotFoundCacheEvent extends BaseEvent<{
|
|
29
20
|
group: string;
|
|
30
21
|
key: string;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* @group Events
|
|
34
|
-
*/
|
|
35
|
-
export declare class KeyNotFoundCacheEvent extends BaseEvent<KeyNotFoundCacheEventFields> {
|
|
36
|
-
group: string;
|
|
37
|
-
key: string;
|
|
38
|
-
static deserialize(serializedEvent: KeyNotFoundCacheEventFields): KeyNotFoundCacheEvent;
|
|
39
|
-
constructor(fields: KeyNotFoundCacheEventFields);
|
|
40
|
-
serialize(): KeyNotFoundCacheEventFields;
|
|
22
|
+
}> {
|
|
41
23
|
}
|
|
42
24
|
/**
|
|
43
25
|
* @group Events
|
|
44
26
|
*/
|
|
45
|
-
export
|
|
27
|
+
export declare class KeyAddedCacheEvent<TType = unknown> extends BaseEvent<{
|
|
46
28
|
group: string;
|
|
47
29
|
key: string;
|
|
48
30
|
value: TType;
|
|
49
31
|
ttl: TimeSpan | null;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* @group Events
|
|
53
|
-
*/
|
|
54
|
-
export declare class KeyAddedCacheEvent<TType = unknown> extends BaseEvent<KeyAddedCacheEventFields<TType>> {
|
|
55
|
-
group: string;
|
|
56
|
-
key: string;
|
|
57
|
-
value: TType;
|
|
58
|
-
ttl: TimeSpan | null;
|
|
59
|
-
static deserialize<TType>(serializedEvent: KeyAddedCacheEventFields<TType>): KeyAddedCacheEvent<TType>;
|
|
60
|
-
constructor(fields: KeyAddedCacheEventFields<TType>);
|
|
61
|
-
serialize(): KeyAddedCacheEventFields<TType>;
|
|
32
|
+
}> {
|
|
62
33
|
}
|
|
63
34
|
/**
|
|
64
35
|
* @group Events
|
|
65
36
|
*/
|
|
66
|
-
export
|
|
67
|
-
group: string;
|
|
68
|
-
key: string;
|
|
69
|
-
value: TType;
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* @group Events
|
|
73
|
-
*/
|
|
74
|
-
export declare class KeyUpdatedCacheEvent<TType = unknown> extends BaseEvent<KeyUpdatedCacheEventFields<TType>> {
|
|
37
|
+
export declare class KeyUpdatedCacheEvent<TType = unknown> extends BaseEvent<{
|
|
75
38
|
group: string;
|
|
76
39
|
key: string;
|
|
77
40
|
value: TType;
|
|
78
|
-
|
|
79
|
-
constructor(fields: KeyUpdatedCacheEventFields<TType>);
|
|
80
|
-
serialize(): KeyUpdatedCacheEventFields<TType>;
|
|
41
|
+
}> {
|
|
81
42
|
}
|
|
82
43
|
/**
|
|
83
44
|
* @group Events
|
|
84
45
|
*/
|
|
85
|
-
export
|
|
86
|
-
group: string;
|
|
87
|
-
key: string;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* @group Events
|
|
91
|
-
*/
|
|
92
|
-
export declare class KeyRemovedCacheEvent extends BaseEvent<KeyRemovedCacheEventFields> {
|
|
46
|
+
export declare class KeyRemovedCacheEvent extends BaseEvent<{
|
|
93
47
|
group: string;
|
|
94
48
|
key: string;
|
|
95
|
-
|
|
96
|
-
constructor(fields: KeyRemovedCacheEventFields);
|
|
97
|
-
serialize(): KeyRemovedCacheEventFields;
|
|
49
|
+
}> {
|
|
98
50
|
}
|
|
99
51
|
/**
|
|
100
52
|
* @group Events
|
|
101
53
|
*/
|
|
102
|
-
export
|
|
103
|
-
group: string;
|
|
104
|
-
key: string;
|
|
105
|
-
value: number;
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* @group Events
|
|
109
|
-
*/
|
|
110
|
-
export declare class KeyIncrementedCacheEvent extends BaseEvent<KeyIncrementedCacheEventFields> {
|
|
54
|
+
export declare class KeyIncrementedCacheEvent extends BaseEvent<{
|
|
111
55
|
group: string;
|
|
112
56
|
key: string;
|
|
113
57
|
value: number;
|
|
114
|
-
|
|
115
|
-
constructor(fields: KeyIncrementedCacheEventFields);
|
|
116
|
-
serialize(): KeyIncrementedCacheEventFields;
|
|
58
|
+
}> {
|
|
117
59
|
}
|
|
118
60
|
/**
|
|
119
61
|
* @group Events
|
|
120
62
|
*/
|
|
121
|
-
export
|
|
63
|
+
export declare class KeyDecrementedCacheEvent extends BaseEvent<{
|
|
122
64
|
group: string;
|
|
123
65
|
key: string;
|
|
124
66
|
value: number;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* @group Events
|
|
128
|
-
*/
|
|
129
|
-
export declare class KeyDecrementedCacheEvent extends BaseEvent<KeyDecrementedCacheEventFields> {
|
|
130
|
-
group: string;
|
|
131
|
-
key: string;
|
|
132
|
-
value: number;
|
|
133
|
-
static deserialize(serializedEvent: KeyDecrementedCacheEventFields): KeyDecrementedCacheEvent;
|
|
134
|
-
constructor(fields: KeyDecrementedCacheEventFields);
|
|
135
|
-
serialize(): KeyDecrementedCacheEventFields;
|
|
67
|
+
}> {
|
|
136
68
|
}
|
|
137
69
|
/**
|
|
138
70
|
* @group Events
|
|
139
71
|
*/
|
|
140
|
-
export
|
|
72
|
+
export declare class KeysClearedCacheEvent extends BaseEvent<{
|
|
141
73
|
group: string;
|
|
142
|
-
}
|
|
74
|
+
}> {
|
|
75
|
+
}
|
|
143
76
|
/**
|
|
144
77
|
* @group Events
|
|
145
78
|
*/
|
|
146
|
-
export
|
|
147
|
-
group: string;
|
|
148
|
-
static deserialize(serializedEvent: KeysClearedCacheEventFields): KeysClearedCacheEvent;
|
|
149
|
-
constructor(fields: KeysClearedCacheEventFields);
|
|
150
|
-
serialize(): KeysClearedCacheEventFields;
|
|
151
|
-
}
|
|
79
|
+
export type CacheEvents<TType = unknown> = KeyFoundCacheEvent<TType> | KeyNotFoundCacheEvent | KeyAddedCacheEvent<TType> | KeyUpdatedCacheEvent<TType> | KeyRemovedCacheEvent | KeyIncrementedCacheEvent | KeyDecrementedCacheEvent | KeysClearedCacheEvent;
|
|
152
80
|
/**
|
|
81
|
+
* The <i>registerCacheEvents</i> function registers all <i>{@link IGroupableCache}</i> related events with <i>IFlexibleSerde</i>, ensuring they will properly be serialized and deserialized.
|
|
153
82
|
* @group Events
|
|
154
83
|
*/
|
|
155
|
-
export
|
|
84
|
+
export declare function registerCacheEvents(serde: OneOrMore<IFlexibleSerde>): void;
|
|
@@ -23,14 +23,14 @@ export type CacheTestSuiteSettings = {
|
|
|
23
23
|
* import Redis from "ioredis";
|
|
24
24
|
* import { afterEach, beforeEach, describe, expect, test } from "vitest";
|
|
25
25
|
* import { RedisContainer, type StartedRedisContainer } from "@testcontainers/redis";
|
|
26
|
-
* import { SuperJsonSerde, TimeSpan, RedisCacheAdapter, cacheTestSuite,
|
|
26
|
+
* import { SuperJsonSerde, TimeSpan, RedisCacheAdapter, cacheTestSuite, MemorycacheAdapter } from "@daiso-tech/core";
|
|
27
27
|
*
|
|
28
28
|
* const TIMEOUT = TimeSpan.fromMinutes(2);
|
|
29
29
|
* describe("class: Cache", () => {
|
|
30
30
|
* let database: Redis;
|
|
31
31
|
* let startedContainer: StartedRedisContainer;
|
|
32
32
|
* const eventBus = new EventBus({
|
|
33
|
-
* adapter: new
|
|
33
|
+
* adapter: new MemorycacheAdapter({
|
|
34
34
|
* rootGroup: "@global"
|
|
35
35
|
* })
|
|
36
36
|
* }):
|
|
@@ -49,22 +49,18 @@ export type CacheTestSuiteSettings = {
|
|
|
49
49
|
* new RedisCacheAdapter({
|
|
50
50
|
* database,
|
|
51
51
|
* serde,
|
|
52
|
-
* }),
|
|
53
|
-
* {
|
|
54
52
|
* rootGroup: "@a",
|
|
55
|
-
*
|
|
56
|
-
* }
|
|
53
|
+
* }),
|
|
54
|
+
* { eventBus }
|
|
57
55
|
* ),
|
|
58
56
|
* createCacheB: () =>
|
|
59
57
|
* new Cache(
|
|
60
58
|
* new RedisCacheAdapter({
|
|
61
59
|
* database,
|
|
62
60
|
* serde,
|
|
63
|
-
* }),
|
|
64
|
-
* {
|
|
65
61
|
* rootGroup: "@b",
|
|
66
|
-
*
|
|
67
|
-
* }
|
|
62
|
+
* }),
|
|
63
|
+
* { eventBus }
|
|
68
64
|
* ),
|
|
69
65
|
* test,
|
|
70
66
|
* beforeEach,
|
|
@@ -50,7 +50,6 @@ export declare class KyselySqliteCacheAdapter<TType = unknown> implements ICache
|
|
|
50
50
|
removeExpiredKeys(): Promise<void>;
|
|
51
51
|
init(): Promise<void>;
|
|
52
52
|
deInit(): Promise<void>;
|
|
53
|
-
exists(key: string): Promise<boolean>;
|
|
54
53
|
get(key: string): Promise<TType | null>;
|
|
55
54
|
add(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
56
55
|
update(key: string, value: TType): Promise<boolean>;
|
package/dist/types/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.d.ts
CHANGED
|
@@ -61,7 +61,6 @@ export declare class LibsqlCacheAdapter<TType = unknown> implements ICacheAdapte
|
|
|
61
61
|
* Creates the table where the cache values are stored and it's related indexes.
|
|
62
62
|
*/
|
|
63
63
|
init(): Promise<void>;
|
|
64
|
-
exists(key: string): Promise<boolean>;
|
|
65
64
|
get(key: string): Promise<TType | null>;
|
|
66
65
|
add(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
67
66
|
update(key: string, value: TType): Promise<boolean>;
|
package/dist/types/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts
CHANGED
|
@@ -52,7 +52,6 @@ export declare class MemoryCacheAdapter<TType = unknown> implements ICacheAdapte
|
|
|
52
52
|
constructor(settings: MemoryCacheAdapterSettings);
|
|
53
53
|
private getGroupName;
|
|
54
54
|
private withPrefix;
|
|
55
|
-
exists(key: string): Promise<boolean>;
|
|
56
55
|
get(key: string): Promise<TType | null>;
|
|
57
56
|
add(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
58
57
|
update(key: string, value: TType): Promise<boolean>;
|
package/dist/types/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts
CHANGED
|
@@ -71,7 +71,6 @@ export declare class MongodbCacheAdapter<TType = unknown> implements ICacheAdapt
|
|
|
71
71
|
* Removes the collection where the cache values are stored and all it's related indexes.
|
|
72
72
|
*/
|
|
73
73
|
deInit(): Promise<void>;
|
|
74
|
-
exists(key: string): Promise<boolean>;
|
|
75
74
|
get(key: string): Promise<TType | null>;
|
|
76
75
|
add(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
77
76
|
update(key: string, value: TType): Promise<boolean>;
|
package/dist/types/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ import type { TimeSpan } from "../../../../utilities/_module";
|
|
|
10
10
|
export declare class NoOpCacheAdapter<TType = unknown> implements ICacheAdapter<TType> {
|
|
11
11
|
getGroup(): string;
|
|
12
12
|
withGroup(_group: string): ICacheAdapter<TType>;
|
|
13
|
-
exists(_key: string): Promise<boolean>;
|
|
14
13
|
get(_key: string): Promise<TType | null>;
|
|
15
14
|
add(_key: string, _value: TType, _ttl: TimeSpan | null): Promise<boolean>;
|
|
16
15
|
update(_key: string, _value: TType): Promise<boolean>;
|
package/dist/types/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts
CHANGED
|
@@ -56,7 +56,6 @@ export declare class RedisCacheAdapter<TType = unknown> implements ICacheAdapter
|
|
|
56
56
|
constructor({ database, serde, rootGroup }: RedisCacheAdapterSettings);
|
|
57
57
|
private getGroupName;
|
|
58
58
|
private withPrefix;
|
|
59
|
-
exists(key: string): Promise<boolean>;
|
|
60
59
|
get(key: string): Promise<TType | null>;
|
|
61
60
|
add(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
62
61
|
update(key: string, value: TType): Promise<boolean>;
|
package/dist/types/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts
CHANGED
|
@@ -61,7 +61,6 @@ export declare class SqliteCacheAdapter<TType = unknown> implements ICacheAdapte
|
|
|
61
61
|
* Creates the table where the cache values are stored and it's related indexes.
|
|
62
62
|
*/
|
|
63
63
|
init(): Promise<void>;
|
|
64
|
-
exists(key: string): Promise<boolean>;
|
|
65
64
|
get(key: string): Promise<TType | null>;
|
|
66
65
|
add(key: string, value: TType, ttl: TimeSpan | null): Promise<boolean>;
|
|
67
66
|
update(key: string, value: TType): Promise<boolean>;
|
|
@@ -2,37 +2,19 @@
|
|
|
2
2
|
* @module Cache
|
|
3
3
|
*/
|
|
4
4
|
import type { ICacheAdapter } from "../../../../cache/contracts/_module";
|
|
5
|
-
import type { IBuildable
|
|
5
|
+
import type { IBuildable } from "../../../../utilities/_module";
|
|
6
6
|
import type { TimeSpan } from "../../../../utilities/_module";
|
|
7
7
|
import type { BackoffPolicy, RetryPolicy } from "../../../../async/_module";
|
|
8
8
|
import type { IGroupableEventBus } from "../../../../event-bus/contracts/_module";
|
|
9
|
-
import type { IFlexibleSerde } from "../../../../serde/contracts/_module";
|
|
10
9
|
/**
|
|
11
10
|
* @group Derivables
|
|
12
11
|
*/
|
|
13
12
|
export type CacheSettings = {
|
|
14
|
-
/**
|
|
15
|
-
* You can pass one or more <i>{@link IFlexibleSerde}</i> that will be used to register all <i>{@link IGroupableCache}</i> related errors and events.
|
|
16
|
-
* @default {true}
|
|
17
|
-
*/
|
|
18
|
-
serde: OneOrMore<IFlexibleSerde>;
|
|
19
|
-
/**
|
|
20
|
-
* If set to true, all <i>{@link IGroupableCache}</i> related errors will be registered with the specified <i>IFlexibleSerde</i> during constructor initialization.
|
|
21
|
-
* This ensures that all <i>{@link IGroupableCache}</i> related errors will be serialized correctly.
|
|
22
|
-
* @default {true}
|
|
23
|
-
*/
|
|
24
|
-
shouldRegisterErrors?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* If set to true, all <i>{@link IGroupableCache}</i> related events will be registered with the specified <i>IFlexibleSerde</i> during constructor initialization.
|
|
27
|
-
* This ensures that all <i>{@link IGroupableCache}</i> related events will be serialized correctly.
|
|
28
|
-
* @default {true}
|
|
29
|
-
*/
|
|
30
|
-
shouldRegisterEvents?: boolean;
|
|
31
13
|
adapter: ICacheAdapter<any>;
|
|
32
14
|
/**
|
|
33
15
|
* In order to listen to events of <i>{@link Cache}</i> class you must pass in <i>{@link IGroupableEventBus}</i>.
|
|
34
16
|
*/
|
|
35
|
-
eventBus
|
|
17
|
+
eventBus: IGroupableEventBus<any>;
|
|
36
18
|
/**
|
|
37
19
|
* You can decide the default ttl value. If null is passed then no ttl will be used by default.
|
|
38
20
|
* @default {null}
|
|
@@ -66,15 +48,6 @@ export type CacheSettings = {
|
|
|
66
48
|
export declare class CacheSettingsBuilder<TSettings extends Partial<CacheSettings>> implements IBuildable<CacheSettings> {
|
|
67
49
|
private readonly settings;
|
|
68
50
|
constructor(settings?: TSettings);
|
|
69
|
-
setShouldRegisterErrors(shouldRegisterErrors: boolean): CacheSettingsBuilder<TSettings & {
|
|
70
|
-
shouldRegisterErrors: boolean;
|
|
71
|
-
}>;
|
|
72
|
-
setShouldRegisterEvents(shouldRegisterEvents: boolean): CacheSettingsBuilder<TSettings & {
|
|
73
|
-
shouldRegisterEvents: boolean;
|
|
74
|
-
}>;
|
|
75
|
-
setSerde(serde: OneOrMore<IFlexibleSerde>): CacheSettingsBuilder<TSettings & {
|
|
76
|
-
serde: OneOrMore<IFlexibleSerde>;
|
|
77
|
-
}>;
|
|
78
51
|
setAdapter(adapter: ICacheAdapter<any>): CacheSettingsBuilder<TSettings & {
|
|
79
52
|
adapter: ICacheAdapter<any>;
|
|
80
53
|
}>;
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* @module Cache
|
|
3
3
|
*/
|
|
4
4
|
import type { CacheEvents, WithTtlValue } from "../../../../cache/contracts/_module";
|
|
5
|
-
import {
|
|
6
|
-
import { CacheError, KeyNotFoundCacheError, TypeCacheError, UnexpectedCacheError } from "../../../../cache/contracts/_module";
|
|
5
|
+
import { type ICache } from "../../../../cache/contracts/_module";
|
|
7
6
|
import { type IGroupableCache } from "../../../../cache/contracts/_module";
|
|
8
7
|
import type { AsyncLazyable, GetOrAddValue, OneOrMore } from "../../../../utilities/_module";
|
|
9
8
|
import type { TimeSpan } from "../../../../utilities/_module";
|
|
@@ -16,22 +15,6 @@ import { CacheSettingsBuilder } from "../../../../cache/implementations/derivabl
|
|
|
16
15
|
* @group Derivables
|
|
17
16
|
*/
|
|
18
17
|
export declare class Cache<TType = unknown> implements IGroupableCache<TType> {
|
|
19
|
-
static readonly errors: {
|
|
20
|
-
readonly Error: typeof CacheError;
|
|
21
|
-
readonly Unexpected: typeof UnexpectedCacheError;
|
|
22
|
-
readonly Type: typeof TypeCacheError;
|
|
23
|
-
readonly KeyNotFound: typeof KeyNotFoundCacheError;
|
|
24
|
-
};
|
|
25
|
-
static readonly events: {
|
|
26
|
-
readonly KeyFound: typeof KeyFoundCacheEvent;
|
|
27
|
-
readonly KeyNotFound: typeof KeyNotFoundCacheEvent;
|
|
28
|
-
readonly KeyAdded: typeof KeyAddedCacheEvent;
|
|
29
|
-
readonly KeyUpdated: typeof KeyUpdatedCacheEvent;
|
|
30
|
-
readonly KeyRemoved: typeof KeyRemovedCacheEvent;
|
|
31
|
-
readonly KeyIncremented: typeof KeyIncrementedCacheEvent;
|
|
32
|
-
readonly KeyDecremented: typeof KeyDecrementedCacheEvent;
|
|
33
|
-
readonly KeysCleared: typeof KeysClearedCacheEvent;
|
|
34
|
-
};
|
|
35
18
|
/**
|
|
36
19
|
* @example
|
|
37
20
|
* ```ts
|
|
@@ -40,10 +23,8 @@ export declare class Cache<TType = unknown> implements IGroupableCache<TType> {
|
|
|
40
23
|
* const cache = new Cache(
|
|
41
24
|
* Cache
|
|
42
25
|
* .settings()
|
|
43
|
-
* .setSerde(new SuperJsonSerde())
|
|
44
26
|
* .setAdapter(new MemoryCacheAdapter({ rootGroup: "@global" }))
|
|
45
27
|
* .setEventBus(new EventBus(new MemoryEventBusAdapter({ rootGroup: "@global" })))
|
|
46
|
-
* .setDefaultTtl(TimeSpan.fromMinutes(2))
|
|
47
28
|
* .build()
|
|
48
29
|
* );
|
|
49
30
|
* ```
|
|
@@ -58,35 +39,26 @@ export declare class Cache<TType = unknown> implements IGroupableCache<TType> {
|
|
|
58
39
|
private readonly backoffPolicy;
|
|
59
40
|
private readonly retryPolicy;
|
|
60
41
|
private readonly timeout;
|
|
61
|
-
private readonly serde;
|
|
62
|
-
private readonly shouldRegisterErrors;
|
|
63
|
-
private readonly shouldRegisterEvents;
|
|
64
42
|
/**
|
|
65
43
|
*@example
|
|
66
44
|
* ```ts
|
|
67
|
-
* import { Cache, MemoryCacheAdapter, EventBus, MemoryEventBusAdapter } from "@daiso-tech/core";
|
|
45
|
+
* import { Cache, MemoryCacheAdapter, EventBus, MemoryEventBusAdapter, registerCacheEvents, reigsterCacheErrors, SuperJsonSerde } from "@daiso-tech/core";
|
|
68
46
|
*
|
|
69
47
|
* const eventBus = new EventBus({
|
|
70
48
|
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
71
49
|
* });
|
|
72
50
|
* const cache = new Cache({
|
|
73
|
-
* serde: new SuperJsonSerde();
|
|
74
51
|
* adapter: new MemoryCacheAdapter({
|
|
75
52
|
* rootGroup: "@global"
|
|
76
53
|
* }),
|
|
77
54
|
* eventBus,
|
|
78
55
|
* });
|
|
56
|
+
* const serde = new SuperJsonSerde();
|
|
57
|
+
* registerCacheEvents(serde);
|
|
58
|
+
* reigsterCacheErrors(serde);
|
|
79
59
|
* ```
|
|
80
60
|
*/
|
|
81
61
|
constructor(settings: CacheSettings);
|
|
82
|
-
/**
|
|
83
|
-
* Registers all cache-related events within the given <i>IFlexibleSerde</i> contract.
|
|
84
|
-
*/
|
|
85
|
-
private registerEvents;
|
|
86
|
-
/**
|
|
87
|
-
* Registers all cache-related error within the given <i>IFlexibleSerde</i> contract.
|
|
88
|
-
*/
|
|
89
|
-
private registerErrors;
|
|
90
62
|
private createLayPromise;
|
|
91
63
|
private createKeyFoundEvent;
|
|
92
64
|
private createKeyNotFoundEvent;
|
package/dist/types/cache/implementations/derivables/cache-factory/cache-factory-settings.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export type CacheFactorySettings<TAdapters extends string = string> = {
|
|
|
40
40
|
/**
|
|
41
41
|
* In order to listen to events of <i>{@link Cache}</i> class you must pass in <i>{@link IGroupableEventBus}</i>.
|
|
42
42
|
*/
|
|
43
|
-
eventBus
|
|
43
|
+
eventBus: IGroupableEventBus<any>;
|
|
44
44
|
/**
|
|
45
45
|
* The default retry attempt to use in the returned <i>LazyPromise</i>.
|
|
46
46
|
* @default {null}
|