@daiso-tech/core 0.32.1 → 0.33.0
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/contracts/cache-factory.contract.d.ts +3 -3
- package/dist/cache/contracts/cache.contract.d.ts +0 -22
- package/dist/cache/contracts/cache.errors.d.ts +1 -1
- package/dist/cache/contracts/cache.errors.js +1 -1
- package/dist/cache/contracts/cache.events.d.ts +2 -12
- package/dist/cache/contracts/cache.events.js +2 -1
- package/dist/cache/contracts/cache.events.js.map +1 -1
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +0 -1
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/derivables/cache/cache.d.ts +9 -139
- package/dist/cache/implementations/derivables/cache/cache.js +28 -219
- package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +6 -6
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
- package/dist/cache/implementations/test-utilities/cache.test-suite.d.ts +2 -2
- package/dist/cache/implementations/test-utilities/cache.test-suite.js +238 -432
- package/dist/cache/implementations/test-utilities/cache.test-suite.js.map +1 -1
- package/dist/event-bus/contracts/event-bus-factory.contract.d.ts +3 -3
- package/dist/event-bus/contracts/event-bus.contract.d.ts +2 -44
- package/dist/event-bus/contracts/event-bus.contract.js.map +1 -1
- package/dist/event-bus/contracts/event-bus.errors.d.ts +1 -1
- package/dist/event-bus/contracts/event-bus.errors.js +1 -1
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +6 -77
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +11 -131
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +4 -4
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.d.ts +2 -2
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js +690 -1431
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js.map +1 -1
- package/dist/lock/contracts/lock-provider-factory.contract.d.ts +3 -3
- package/dist/lock/contracts/lock-provider.contract.d.ts +10 -20
- package/dist/lock/contracts/lock.contract.d.ts +1 -10
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +12 -155
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +31 -228
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.d.ts +5 -5
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js +7 -30
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +8 -58
- package/dist/lock/implementations/derivables/lock-provider/lock.js +33 -105
- package/dist/lock/implementations/derivables/lock-provider/lock.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.d.ts +9 -8
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.d.ts +2 -2
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +178 -659
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
- package/dist/utilities/classes/key-prefixer/_module.d.ts +0 -1
- package/dist/utilities/classes/key-prefixer/_module.js +0 -1
- package/dist/utilities/classes/key-prefixer/_module.js.map +1 -1
- package/dist/utilities/classes/key-prefixer/key-prefixer.d.ts +4 -31
- package/dist/utilities/classes/key-prefixer/key-prefixer.js +6 -66
- package/dist/utilities/classes/key-prefixer/key-prefixer.js.map +1 -1
- package/package.json +1 -1
- package/dist/async/utilities/lazy-promise/lazy-promise-event-bus.d.ts +0 -15
- package/dist/async/utilities/lazy-promise/lazy-promise-event-bus.js +0 -50
- package/dist/async/utilities/lazy-promise/lazy-promise-event-bus.js.map +0 -1
- package/dist/async/utilities/lazy-promise/lazy-promise-listener.contract.d.ts +0 -23
- package/dist/async/utilities/lazy-promise/lazy-promise-listener.contract.js +0 -44
- package/dist/async/utilities/lazy-promise/lazy-promise-listener.contract.js.map +0 -1
- package/dist/utilities/classes/key-prefixer/key-prefixer.contract.d.ts +0 -28
- package/dist/utilities/classes/key-prefixer/key-prefixer.contract.js +0 -5
- package/dist/utilities/classes/key-prefixer/key-prefixer.contract.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Cache
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
4
|
+
import type { ICache } from "../../cache/contracts/cache.contract.js";
|
|
5
5
|
/**
|
|
6
|
-
* The <i>ICacheFactory</i> contract makes it easy to configure and switch between different <i>{@link
|
|
6
|
+
* The <i>ICacheFactory</i> contract makes it easy to configure and switch between different <i>{@link ICache}</i> dynamically.
|
|
7
7
|
*
|
|
8
8
|
* IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
|
|
9
9
|
* @group Contracts
|
|
@@ -15,5 +15,5 @@ export type ICacheFactory<TAdapters extends string = string> = {
|
|
|
15
15
|
* @throws {UnregisteredAdapterError} {@link UnregisteredAdapterError}
|
|
16
16
|
* @throws {DefaultAdapterNotDefinedError} {@link DefaultAdapterNotDefinedError}
|
|
17
17
|
*/
|
|
18
|
-
use<TType = unknown>(adapterName?: TAdapters):
|
|
18
|
+
use<TType = unknown>(adapterName?: TAdapters): ICache<TType>;
|
|
19
19
|
};
|
|
@@ -172,10 +172,6 @@ export type ICacheBase<TType = unknown> = {
|
|
|
172
172
|
* The <i>clear</i> method removes all the keys in the cache. If a cache is in a group then only the keys part of the group will be removed.
|
|
173
173
|
*/
|
|
174
174
|
clear(): LazyPromise<void>;
|
|
175
|
-
/**
|
|
176
|
-
* The <i>getGroup</i> method returns the group name of the cache. If the cache is not part of a group then null is returned.
|
|
177
|
-
*/
|
|
178
|
-
getGroup(): string | null;
|
|
179
175
|
};
|
|
180
176
|
/**
|
|
181
177
|
* The <i>ICache</i> contract defines a way for as key-value pairs independent of data storage and listening to operation events.
|
|
@@ -184,21 +180,3 @@ export type ICacheBase<TType = unknown> = {
|
|
|
184
180
|
* @group Contracts
|
|
185
181
|
*/
|
|
186
182
|
export type ICache<TType = unknown> = ICacheListenable<TType> & ICacheBase<TType>;
|
|
187
|
-
/**
|
|
188
|
-
* The <i>IGroupableCache</i> contract defines a way for storing and grouping data as key-value pairs independent of data storage.
|
|
189
|
-
*
|
|
190
|
-
* IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
|
|
191
|
-
* @group Contracts
|
|
192
|
-
*/
|
|
193
|
-
export type IGroupableCache<TType = unknown> = ICache<TType> & {
|
|
194
|
-
/**
|
|
195
|
-
* The <i>withGroup</i> method returns a new <i>{@link ICache}</i> instance that groups keys together.
|
|
196
|
-
* Only keys in the same group will be updated, removed, or retrieved, leaving keys outside the group unaffected.
|
|
197
|
-
* This useful for multitennat applications.
|
|
198
|
-
*
|
|
199
|
-
* @param group - can be a string or an <i>Iterable</i> of strings.
|
|
200
|
-
* If it's an <i>Iterable</i>, it will be joined into a single string.
|
|
201
|
-
* Think of an <i>Iterable</i> as representing a path.
|
|
202
|
-
*/
|
|
203
|
-
withGroup(group: OneOrMore<string>): ICache<TType>;
|
|
204
|
-
};
|
|
@@ -54,7 +54,7 @@ export declare const CACHE_ERRORS: {
|
|
|
54
54
|
readonly KeyNotFound: typeof KeyNotFoundCacheError;
|
|
55
55
|
};
|
|
56
56
|
/**
|
|
57
|
-
* The <i>registerCacheErrorsToSerde</i> function registers all <i>{@link
|
|
57
|
+
* The <i>registerCacheErrorsToSerde</i> function registers all <i>{@link ICache}</i> related errors with <i>IFlexibleSerde</i>, ensuring they will properly be serialized and deserialized.
|
|
58
58
|
*
|
|
59
59
|
* IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
|
|
60
60
|
* @group Errors
|
|
@@ -79,7 +79,7 @@ export const CACHE_ERRORS = {
|
|
|
79
79
|
KeyNotFound: KeyNotFoundCacheError,
|
|
80
80
|
};
|
|
81
81
|
/**
|
|
82
|
-
* The <i>registerCacheErrorsToSerde</i> function registers all <i>{@link
|
|
82
|
+
* The <i>registerCacheErrorsToSerde</i> function registers all <i>{@link ICache}</i> related errors with <i>IFlexibleSerde</i>, ensuring they will properly be serialized and deserialized.
|
|
83
83
|
*
|
|
84
84
|
* IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
|
|
85
85
|
* @group Errors
|
|
@@ -11,7 +11,6 @@ import { type OneOrMore, type TimeSpan } from "../../utilities/_module-exports.j
|
|
|
11
11
|
* @group Events
|
|
12
12
|
*/
|
|
13
13
|
export declare class KeyFoundCacheEvent<TType = unknown> extends BaseEvent<{
|
|
14
|
-
group: string | null;
|
|
15
14
|
key: string;
|
|
16
15
|
value: TType;
|
|
17
16
|
}> {
|
|
@@ -23,7 +22,6 @@ export declare class KeyFoundCacheEvent<TType = unknown> extends BaseEvent<{
|
|
|
23
22
|
* @group Events
|
|
24
23
|
*/
|
|
25
24
|
export declare class KeyNotFoundCacheEvent extends BaseEvent<{
|
|
26
|
-
group: string | null;
|
|
27
25
|
key: string;
|
|
28
26
|
}> {
|
|
29
27
|
}
|
|
@@ -34,7 +32,6 @@ export declare class KeyNotFoundCacheEvent extends BaseEvent<{
|
|
|
34
32
|
* @group Events
|
|
35
33
|
*/
|
|
36
34
|
export declare class KeyAddedCacheEvent<TType = unknown> extends BaseEvent<{
|
|
37
|
-
group: string | null;
|
|
38
35
|
key: string;
|
|
39
36
|
value: TType;
|
|
40
37
|
ttl: TimeSpan | null;
|
|
@@ -47,7 +44,6 @@ export declare class KeyAddedCacheEvent<TType = unknown> extends BaseEvent<{
|
|
|
47
44
|
* @group Events
|
|
48
45
|
*/
|
|
49
46
|
export declare class KeyUpdatedCacheEvent<TType = unknown> extends BaseEvent<{
|
|
50
|
-
group: string | null;
|
|
51
47
|
key: string;
|
|
52
48
|
value: TType;
|
|
53
49
|
}> {
|
|
@@ -59,7 +55,6 @@ export declare class KeyUpdatedCacheEvent<TType = unknown> extends BaseEvent<{
|
|
|
59
55
|
* @group Events
|
|
60
56
|
*/
|
|
61
57
|
export declare class KeyRemovedCacheEvent extends BaseEvent<{
|
|
62
|
-
group: string | null;
|
|
63
58
|
key: string;
|
|
64
59
|
}> {
|
|
65
60
|
}
|
|
@@ -70,7 +65,6 @@ export declare class KeyRemovedCacheEvent extends BaseEvent<{
|
|
|
70
65
|
* @group Events
|
|
71
66
|
*/
|
|
72
67
|
export declare class KeyIncrementedCacheEvent extends BaseEvent<{
|
|
73
|
-
group: string | null;
|
|
74
68
|
key: string;
|
|
75
69
|
value: number;
|
|
76
70
|
}> {
|
|
@@ -82,7 +76,6 @@ export declare class KeyIncrementedCacheEvent extends BaseEvent<{
|
|
|
82
76
|
* @group Events
|
|
83
77
|
*/
|
|
84
78
|
export declare class KeyDecrementedCacheEvent extends BaseEvent<{
|
|
85
|
-
group: string | null;
|
|
86
79
|
key: string;
|
|
87
80
|
value: number;
|
|
88
81
|
}> {
|
|
@@ -93,9 +86,7 @@ export declare class KeyDecrementedCacheEvent extends BaseEvent<{
|
|
|
93
86
|
* IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
|
|
94
87
|
* @group Events
|
|
95
88
|
*/
|
|
96
|
-
export declare class KeysClearedCacheEvent extends BaseEvent<{
|
|
97
|
-
group: string | null;
|
|
98
|
-
}> {
|
|
89
|
+
export declare class KeysClearedCacheEvent extends BaseEvent<{}> {
|
|
99
90
|
}
|
|
100
91
|
/**
|
|
101
92
|
*
|
|
@@ -103,7 +94,6 @@ export declare class KeysClearedCacheEvent extends BaseEvent<{
|
|
|
103
94
|
* @group Events
|
|
104
95
|
*/
|
|
105
96
|
export declare class UnexpectedErrorCacheEvent extends BaseEvent<{
|
|
106
|
-
group: string | null;
|
|
107
97
|
keys?: string[];
|
|
108
98
|
value?: unknown;
|
|
109
99
|
method: string;
|
|
@@ -133,7 +123,7 @@ export declare const CACHE_EVENTS: {
|
|
|
133
123
|
*/
|
|
134
124
|
export type CacheEvents<TType = unknown> = KeyFoundCacheEvent<TType> | KeyNotFoundCacheEvent | KeyAddedCacheEvent<TType> | KeyUpdatedCacheEvent<TType> | KeyRemovedCacheEvent | KeyIncrementedCacheEvent | KeyDecrementedCacheEvent | KeysClearedCacheEvent | UnexpectedErrorCacheEvent;
|
|
135
125
|
/**
|
|
136
|
-
* The <i>registerCacheEventsToSerde</i> function registers all <i>{@link
|
|
126
|
+
* The <i>registerCacheEventsToSerde</i> function registers all <i>{@link ICache}</i> related events with <i>IFlexibleSerde</i>, ensuring they will properly be serialized and deserialized.
|
|
137
127
|
*
|
|
138
128
|
* IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
|
|
139
129
|
* @group Events
|
|
@@ -65,6 +65,7 @@ export class KeyDecrementedCacheEvent extends BaseEvent {
|
|
|
65
65
|
* IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
|
|
66
66
|
* @group Events
|
|
67
67
|
*/
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
68
69
|
export class KeysClearedCacheEvent extends BaseEvent {
|
|
69
70
|
}
|
|
70
71
|
/**
|
|
@@ -91,7 +92,7 @@ export const CACHE_EVENTS = {
|
|
|
91
92
|
UnexpectedError: UnexpectedErrorCacheEvent,
|
|
92
93
|
};
|
|
93
94
|
/**
|
|
94
|
-
* The <i>registerCacheEventsToSerde</i> function registers all <i>{@link
|
|
95
|
+
* The <i>registerCacheEventsToSerde</i> function registers all <i>{@link ICache}</i> related events with <i>IFlexibleSerde</i>, ensuring they will properly be serialized and deserialized.
|
|
95
96
|
*
|
|
96
97
|
* IMPORT_PATH: ```"@daiso-tech/core/cache/contracts"```
|
|
97
98
|
* @group Events
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.events.js","sourceRoot":"","sources":["../../../src/cache/contracts/cache.events.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAErE,OAAO,EACH,IAAI,EACJ,gBAAgB,GAGnB,MAAM,gCAAgC,CAAC;AAExC;;;;;GAKG;AACH,MAAM,OAAO,kBAAoC,SAAQ,
|
|
1
|
+
{"version":3,"file":"cache.events.js","sourceRoot":"","sources":["../../../src/cache/contracts/cache.events.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAErE,OAAO,EACH,IAAI,EACJ,gBAAgB,GAGnB,MAAM,gCAAgC,CAAC;AAExC;;;;;GAKG;AACH,MAAM,OAAO,kBAAoC,SAAQ,SAGvD;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,qBAAsB,SAAQ,SAEzC;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,kBAAoC,SAAQ,SAIvD;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,oBAAsC,SAAQ,SAGzD;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,oBAAqB,SAAQ,SAExC;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,wBAAyB,SAAQ,SAG5C;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,wBAAyB,SAAQ,SAG5C;CAAG;AAEL;;;;;GAKG;AACH,mEAAmE;AACnE,MAAM,OAAO,qBAAsB,SAAQ,SAAa;CAAG;AAE3D;;;;GAIG;AACH,MAAM,OAAO,yBAA0B,SAAQ,SAK7C;CAAG;AAEL;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,QAAQ,EAAE,kBAAkB;IAC5B,WAAW,EAAE,qBAAqB;IAClC,QAAQ,EAAE,kBAAkB;IAC5B,UAAU,EAAE,oBAAoB;IAChC,UAAU,EAAE,oBAAoB;IAChC,cAAc,EAAE,wBAAwB;IACxC,cAAc,EAAE,wBAAwB;IACxC,WAAW,EAAE,qBAAqB;IAClC,eAAe,EAAE,yBAAyB;CAC7C,CAAC;AAkBF;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CACtC,KAAgC;IAEhC,KAAK,MAAM,MAAM,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3C,MAAM;aACD,aAAa,CAAC,kBAAkB,EAAE,IAAI,CAAC;aACvC,aAAa,CAAC,qBAAqB,EAAE,IAAI,CAAC;aAC1C,aAAa,CAAC,kBAAkB,EAAE,IAAI,CAAC;aACvC,aAAa,CAAC,oBAAoB,EAAE,IAAI,CAAC;aACzC,aAAa,CAAC,oBAAoB,EAAE,IAAI,CAAC;aACzC,aAAa,CAAC,wBAAwB,EAAE,IAAI,CAAC;aAC7C,aAAa,CAAC,wBAAwB,EAAE,IAAI,CAAC;aAC7C,aAAa,CAAC,qBAAqB,EAAE,IAAI,CAAC;aAC1C,aAAa,CAAC,yBAAyB,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;AACL,CAAC"}
|
package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-cache-adapter.js","sourceRoot":"","sources":["../../../../../src/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACH,cAAc,EACd,oBAAoB,GAEvB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uFAAuF,CAAC;AAMjI,OAAO,EAAE,gBAAgB,EAAiB,MAAM,SAAS,CAAC;AAC1D,OAAO,EAKN,MAAM,SAAS,CAAC;AACjB,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AA0BtD;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IAGpB,MAAM,CAAC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AI;QACN,IAAI,CAAC;YACD,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAC7B;gBACI,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"mongodb-cache-adapter.js","sourceRoot":"","sources":["../../../../../src/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACH,cAAc,EACd,oBAAoB,GAEvB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uFAAuF,CAAC;AAMjI,OAAO,EAAE,gBAAgB,EAAiB,MAAM,SAAS,CAAC;AAC1D,OAAO,EAKN,MAAM,SAAS,CAAC;AACjB,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AA0BtD;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IAGpB,MAAM,CAAC,mBAAmB,CAC9B,IAAc;QAEd,MAAM,eAAe,GAAiC;YAClD,UAAU,EAAE;gBACR,GAAG,EAAE,IAAI;aACZ;SACJ,CAAC;QACF,MAAM,aAAa,GAAiC;YAChD,UAAU,EAAE;gBACR,GAAG,EAAE,IAAI;aACZ;SACJ,CAAC;QACF,MAAM,aAAa,GAAiC;YAChD,UAAU,EAAE;gBACR,GAAG,EAAE,IAAI,IAAI,EAAE;aAClB;SACJ,CAAC;QACF,MAAM,SAAS,GAAG;YACd,GAAG,EAAE;gBACD,GAAG,EAAE,IAAI;aACZ;SACJ,CAAC;QACF,OAAO;YACH,IAAI,EAAE;gBACF,SAAS;gBACT;oBACI,GAAG,EAAE;wBACD,eAAe;wBACf;4BACI,IAAI,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC;yBACvC;qBACJ;iBACJ;aACJ;SACJ,CAAC;IACN,CAAC;IAEO,MAAM,CAAC,uBAAuB,CAClC,KAAc;QAEd,OAAO,CACH,KAAK,YAAY,gBAAgB;YACjC,KAAK,CAAC,IAAI,KAAK,SAAS;YACxB,CAAC,OAAO,KAAK,C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AAC,uBAAuB,CAAC,KAAK,CAAC,EAAE,CAAC;gBACrD,MAAM,IAAI,cAAc,CACpB,0DAA0D,GAAG,GAAG,CACnE,CAAC;YACN,CAAC;YACD,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,IAAc;QAC3B,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,CACjD,mBAAmB,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAChD,CAAC;QACF,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC;YAC7B,MAAM,IAAI,oBAAoB,CAC1B,uCAAuC,CAC1C,CAAC;QACN,CAAC;QACD,OAAO,YAAY,CAAC,YAAY,GAAG,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,SAAS;QACX,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;QACzD,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC;YAC9B,MAAM,IAAI,oBAAoB,CAC1B,uCAAuC,CAC1C,CAAC;QACN,CAAC;IACL,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,MAAc;QAClC,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;YACnD,GAAG,EAAE;gBACD,MAAM,EAAE,IAAI,MAAM,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC;aACvD;SACJ,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC;YAC9B,MAAM,IAAI,oBAAoB,CAC1B,uCAAuC,CAC1C,CAAC;QACN,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -3,19 +3,18 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { CacheEvents, IDatabaseCacheAdapter } from "../../../../cache/contracts/_module-exports.js";
|
|
5
5
|
import { type ICache, type ICacheAdapter } from "../../../../cache/contracts/_module-exports.js";
|
|
6
|
-
import { type IGroupableCache } from "../../../../cache/contracts/_module-exports.js";
|
|
7
6
|
import { type AsyncLazyable, type OneOrMore } from "../../../../utilities/_module-exports.js";
|
|
8
|
-
import { type NoneFunc, type TimeSpan,
|
|
7
|
+
import { type NoneFunc, type TimeSpan, KeyPrefixer } from "../../../../utilities/_module-exports.js";
|
|
9
8
|
import { LazyPromise } from "../../../../async/_module-exports.js";
|
|
10
|
-
import type {
|
|
11
|
-
import type { AsyncLazy, Factory
|
|
9
|
+
import type { IEventBus, Unsubscribe, EventClass, EventInstance, EventListener } from "../../../../event-bus/contracts/_module-exports.js";
|
|
10
|
+
import type { AsyncLazy, Factory } from "../../../../utilities/_module-exports.js";
|
|
12
11
|
/**
|
|
13
12
|
*
|
|
14
13
|
* IMPORT_PATH: ```"@daiso-tech/core/cache"```
|
|
15
14
|
* @group Derivables
|
|
16
15
|
*/
|
|
17
16
|
export type CacheSettingsBase = {
|
|
18
|
-
keyPrefixer:
|
|
17
|
+
keyPrefixer: KeyPrefixer;
|
|
19
18
|
/**
|
|
20
19
|
* You can pass a <i>{@link Factory}</i> of <i>{@link LazyPromise}</i> to configure default settings for all <i>{@link LazyPromise}</i> instances used in the <i>Cache</i> class.
|
|
21
20
|
* @default
|
|
@@ -39,7 +38,7 @@ export type CacheSettingsBase = {
|
|
|
39
38
|
* })
|
|
40
39
|
* ```
|
|
41
40
|
*/
|
|
42
|
-
eventBus?:
|
|
41
|
+
eventBus?: IEventBus<any>;
|
|
43
42
|
/**
|
|
44
43
|
* You can decide the default ttl value. If null is passed then no ttl will be used by default.
|
|
45
44
|
* @default {null}
|
|
@@ -51,28 +50,25 @@ export type CacheSettingsBase = {
|
|
|
51
50
|
* IMPORT_PATH: ```"@daiso-tech/core/cache"```
|
|
52
51
|
* @group Derivables
|
|
53
52
|
*/
|
|
54
|
-
export type
|
|
53
|
+
export type CacheAdapter<TType> = ICacheAdapter<TType> | IDatabaseCacheAdapter<TType>;
|
|
55
54
|
/**
|
|
56
55
|
*
|
|
57
56
|
* IMPORT_PATH: ```"@daiso-tech/core/cache"```
|
|
58
57
|
* @group Derivables
|
|
59
58
|
*/
|
|
60
59
|
export type CacheSettings = CacheSettingsBase & {
|
|
61
|
-
adapter:
|
|
60
|
+
adapter: CacheAdapter<any>;
|
|
62
61
|
};
|
|
63
62
|
/**
|
|
64
63
|
*
|
|
65
64
|
* IMPORT_PATH: ```"@daiso-tech/core/cache"```
|
|
66
65
|
* @group Derivables
|
|
67
66
|
*/
|
|
68
|
-
export declare class Cache<TType = unknown> implements
|
|
69
|
-
private static resolveCacheAdapter;
|
|
70
|
-
private static resolveCacheAdapterFactoryable;
|
|
67
|
+
export declare class Cache<TType = unknown> implements ICache<TType> {
|
|
71
68
|
private static defaultRetryPolicy;
|
|
72
|
-
private readonly groupdEventBus;
|
|
73
69
|
private readonly eventBus;
|
|
74
70
|
private readonly adapterFactoryable;
|
|
75
|
-
private readonly
|
|
71
|
+
private readonly adapter;
|
|
76
72
|
private readonly defaultTtl;
|
|
77
73
|
private readonly keyPrefixer;
|
|
78
74
|
private readonly lazyPromiseFactory;
|
|
@@ -101,72 +97,6 @@ export declare class Cache<TType = unknown> implements IGroupableCache<TType> {
|
|
|
101
97
|
* adapter: cacheAdapter,
|
|
102
98
|
* });
|
|
103
99
|
* ```
|
|
104
|
-
*
|
|
105
|
-
* You can pass factory function that will create an adapter for every group.
|
|
106
|
-
* @example
|
|
107
|
-
* ```ts
|
|
108
|
-
* import { SqliteCacheAdapter } from "@daiso-tech/core/cache/adapters";
|
|
109
|
-
* import type { IDatabaseCacheAdapter } from "@daiso-tech/core/cache/contracts";
|
|
110
|
-
* import { Serde } from "@daiso-tech/core/serde";
|
|
111
|
-
* import type { ISerde } from "@daiso-tech/core/serde/contracts";
|
|
112
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
|
|
113
|
-
* import Sqlite from "better-sqlite3";
|
|
114
|
-
* import { Cache } from "@daiso-tech/core/cache";
|
|
115
|
-
* import { KeyPrefixer, type ISqliteDatabase, type AsyncFactoryFn } from "@daiso-tech/core/utilities";
|
|
116
|
-
*
|
|
117
|
-
* function cahceAdapterFactory(database: ISqliteDatabase, serde: ISerde<string>): AsyncFactoryFn<string, IDatabaseCacheAdapter> {
|
|
118
|
-
* return async (prefix) => {
|
|
119
|
-
* const cacheAdapter = new SqliteCacheAdapter({
|
|
120
|
-
* database,
|
|
121
|
-
* serde,
|
|
122
|
-
* tableName: `cache_${prefix}`
|
|
123
|
-
* });
|
|
124
|
-
* await cacheAdapter.init();
|
|
125
|
-
* return cacheAdapter;
|
|
126
|
-
* }
|
|
127
|
-
* }
|
|
128
|
-
*
|
|
129
|
-
* const database = new Sqlite("local.db");
|
|
130
|
-
* const serde = new Serde(new SuperJsonSerdeAdapter());
|
|
131
|
-
* const cache = new Cache({
|
|
132
|
-
* keyPrefixer: new KeyPrefixer("cache"),
|
|
133
|
-
* adapter: cahceAdapterFactory(database, serde),
|
|
134
|
-
* });
|
|
135
|
-
* ```
|
|
136
|
-
*
|
|
137
|
-
* You can also pass factory object that implements <i>{@link IFactoryObject}</i> contract. This useful for depedency injection libraries.
|
|
138
|
-
* @example
|
|
139
|
-
* ```ts
|
|
140
|
-
* import { SqliteCacheAdapter } from "@daiso-tech/core/cache/adapters";
|
|
141
|
-
* import type { IDatabaseCacheAdapter } from "@daiso-tech/core/cache/contracts";
|
|
142
|
-
* import { Serde } from "@daiso-tech/core/serde";
|
|
143
|
-
* import type { ISerde } from "@daiso-tech/core/serde/contracts";
|
|
144
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
|
|
145
|
-
* import Sqlite from "better-sqlite3";
|
|
146
|
-
* import { Cache } from "@daiso-tech/core/cache";
|
|
147
|
-
* import { KeyPrefixer, type ISqliteDatabase, type IAsyncFactoryObject } from "@daiso-tech/core/utilities";
|
|
148
|
-
*
|
|
149
|
-
* class CahceAdapterFactory implements IAsyncFactoryObject<string, IDatabaseCacheAdapter> {
|
|
150
|
-
* constructor(private readonly database: ISqliteDatabase, private readonly serde: ISerde<string>) {}
|
|
151
|
-
*
|
|
152
|
-
* async use(prefix: string): Promise<IDatabaseCacheAdapter> {
|
|
153
|
-
* const cacheAdapter = new SqliteCacheAdapter({
|
|
154
|
-
* database: this.database,
|
|
155
|
-
* serde: this.serde,
|
|
156
|
-
* tableName: `cache_${prefix}`
|
|
157
|
-
* });
|
|
158
|
-
* await cacheAdapter.init();
|
|
159
|
-
* return cacheAdapter;
|
|
160
|
-
* }
|
|
161
|
-
* }
|
|
162
|
-
*
|
|
163
|
-
* const database = new Sqlite("local.db");
|
|
164
|
-
* const serde = new Serde(new SuperJsonSerdeAdapter());
|
|
165
|
-
* const cache = new Cache({
|
|
166
|
-
* keyPrefixer: new KeyPrefixer("cache"),
|
|
167
|
-
* adapter: new CahceAdapterFactory(database, serde),
|
|
168
|
-
* });
|
|
169
|
-
* ```
|
|
170
100
|
*/
|
|
171
101
|
constructor(settings: CacheSettings);
|
|
172
102
|
/**
|
|
@@ -174,21 +104,11 @@ export declare class Cache<TType = unknown> implements IGroupableCache<TType> {
|
|
|
174
104
|
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
175
105
|
*/
|
|
176
106
|
addListener<TEventClass extends EventClass<CacheEvents<TType>>>(event: TEventClass, listener: EventListener<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
177
|
-
/**
|
|
178
|
-
* You can listen to the following <i>{@link CacheEvents}</i> of the <i>{@link ICache}</i> instance.
|
|
179
|
-
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
180
|
-
*/
|
|
181
|
-
addListenerMany<TEventClassArr extends EventClass<CacheEvents<TType>>[]>(events: [...TEventClassArr], listener: EventListener<EventInstance<Items<TEventClassArr>>>): LazyPromise<void>;
|
|
182
107
|
/**
|
|
183
108
|
* You can listen to the following <i>{@link CacheEvents}</i> of the <i>{@link ICache}</i> instance.
|
|
184
109
|
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
185
110
|
*/
|
|
186
111
|
removeListener<TEventClass extends EventClass<CacheEvents<TType>>>(event: TEventClass, listener: EventListener<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
187
|
-
/**
|
|
188
|
-
* You can listen to the following <i>{@link CacheEvents}</i> of the <i>{@link ICache}</i> instance.
|
|
189
|
-
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
190
|
-
*/
|
|
191
|
-
removeListenerMany<TEventClassArr extends EventClass<CacheEvents<TType>>[]>(events: [...TEventClassArr], listener: EventListener<EventInstance<Items<TEventClassArr>>>): LazyPromise<void>;
|
|
192
112
|
/**
|
|
193
113
|
* You can listen to the following <i>{@link CacheEvents}</i> of the <i>{@link ICache}</i> instance.
|
|
194
114
|
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
@@ -209,11 +129,6 @@ export declare class Cache<TType = unknown> implements IGroupableCache<TType> {
|
|
|
209
129
|
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
210
130
|
*/
|
|
211
131
|
subscribe<TEventClass extends EventClass<CacheEvents<TType>>>(event: TEventClass, listener: EventListener<EventInstance<TEventClass>>): LazyPromise<Unsubscribe>;
|
|
212
|
-
/**
|
|
213
|
-
* You can listen to the following <i>{@link CacheEvents}</i> of the <i>{@link ICache}</i> instance.
|
|
214
|
-
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
215
|
-
*/
|
|
216
|
-
subscribeMany<TEventClassArr extends EventClass<CacheEvents<TType>>[]>(events: [...TEventClassArr], listener: EventListener<EventInstance<Items<TEventClassArr>>>): LazyPromise<Unsubscribe>;
|
|
217
132
|
private createLazyPromise;
|
|
218
133
|
exists(key: OneOrMore<string>): LazyPromise<boolean>;
|
|
219
134
|
missing(key: OneOrMore<string>): LazyPromise<boolean>;
|
|
@@ -230,49 +145,4 @@ export declare class Cache<TType = unknown> implements IGroupableCache<TType> {
|
|
|
230
145
|
remove(key: OneOrMore<string>): LazyPromise<boolean>;
|
|
231
146
|
removeMany(keys: Iterable<OneOrMore<string>>): LazyPromise<boolean>;
|
|
232
147
|
clear(): LazyPromise<void>;
|
|
233
|
-
/**
|
|
234
|
-
* @example
|
|
235
|
-
* ```ts
|
|
236
|
-
* import { Cache } from "@daiso-tech/core/cache";
|
|
237
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/adapters";
|
|
238
|
-
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
239
|
-
*
|
|
240
|
-
* const cache = new Cache({
|
|
241
|
-
* adapter: new MemoryCacheAdapter(),
|
|
242
|
-
* keyPrefixer: new KeyPrefixer("cache")
|
|
243
|
-
* });
|
|
244
|
-
*
|
|
245
|
-
* // Will log null because the cache is not in a group
|
|
246
|
-
* console.log(cache.getGroup());
|
|
247
|
-
*
|
|
248
|
-
* const groupedCache = cache.withGroup("group-a");
|
|
249
|
-
*
|
|
250
|
-
* // Will log "group-a" because the groupedCache is in a group
|
|
251
|
-
* console.log(groupedCache.getGroup());
|
|
252
|
-
* ```
|
|
253
|
-
*/
|
|
254
|
-
getGroup(): string | null;
|
|
255
|
-
/**
|
|
256
|
-
* @example
|
|
257
|
-
* ```ts
|
|
258
|
-
* import { Cache } from "@daiso-tech/core/cache";
|
|
259
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/adapters";
|
|
260
|
-
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
261
|
-
*
|
|
262
|
-
* const cache = new Cache({
|
|
263
|
-
* adapter: new MemoryCacheAdapter(),
|
|
264
|
-
* keyPrefixer: new KeyPrefixer("cache")
|
|
265
|
-
* });
|
|
266
|
-
*
|
|
267
|
-
* const groupedCache = cache.withGroup("group-a");
|
|
268
|
-
* await groupedCache.add("a", 1);
|
|
269
|
-
*
|
|
270
|
-
* // Will log "a".
|
|
271
|
-
* console.log(await groupedCache.get("a"));
|
|
272
|
-
*
|
|
273
|
-
* // Will log null because the caches are in different groups.
|
|
274
|
-
* console.log(await cache.get("a"));
|
|
275
|
-
* ```
|
|
276
|
-
*/
|
|
277
|
-
withGroup(group: OneOrMore<string>): ICache<TType>;
|
|
278
148
|
}
|