@daiso-tech/core 0.26.0 → 0.27.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/README.md +10 -0
- package/dist/async/utilities/delay/delay.d.ts +1 -12
- package/dist/async/utilities/delay/delay.js +1 -12
- package/dist/async/utilities/delay/delay.js.map +1 -1
- package/dist/async/utilities/lazy-promise/lazy-promise.d.ts +99 -65
- package/dist/async/utilities/lazy-promise/lazy-promise.js +151 -111
- package/dist/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
- package/dist/cache/contracts/_module-exports.d.ts +1 -0
- package/dist/cache/contracts/_module-exports.js +1 -0
- package/dist/cache/contracts/_module-exports.js.map +1 -1
- package/dist/cache/contracts/cache-adapter.contract.d.ts +19 -21
- package/dist/cache/contracts/cache-adapter.contract.js +1 -4
- package/dist/cache/contracts/cache-adapter.contract.js.map +1 -1
- package/dist/cache/contracts/cache-factory.contract.d.ts +1 -1
- package/dist/cache/contracts/cache.contract.d.ts +52 -88
- package/dist/cache/contracts/cache.contract.js +1 -2
- package/dist/cache/contracts/cache.contract.js.map +1 -1
- package/dist/cache/contracts/cache.errors.js +2 -5
- package/dist/cache/contracts/cache.errors.js.map +1 -1
- package/dist/cache/contracts/cache.events.d.ts +10 -10
- package/dist/cache/contracts/cache.events.js +2 -5
- package/dist/cache/contracts/cache.events.js.map +1 -1
- package/dist/cache/contracts/database-cache-adapter.contract.d.ts +89 -0
- package/dist/cache/contracts/database-cache-adapter.contract.js +5 -0
- package/dist/cache/contracts/database-cache-adapter.contract.js.map +1 -0
- package/dist/cache/implementations/adapters/_module-exports.d.ts +0 -1
- package/dist/cache/implementations/adapters/_module-exports.js +0 -1
- package/dist/cache/implementations/adapters/_module-exports.js.map +1 -1
- package/dist/cache/implementations/adapters/{kysely-sqlite-cache-adapter → kysely-cache-adapter}/_module.d.ts +1 -1
- package/dist/cache/implementations/adapters/kysely-cache-adapter/_module.js +2 -0
- package/dist/cache/implementations/adapters/kysely-cache-adapter/_module.js.map +1 -0
- package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.d.ts +73 -0
- package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js +224 -0
- package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js.map +1 -0
- package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.d.ts +29 -39
- package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +45 -54
- package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts +17 -33
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +43 -52
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.d.ts +13 -0
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js +38 -0
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js.map +1 -0
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts +27 -33
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +145 -197
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.d.ts +13 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.js +39 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.js.map +1 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts +16 -22
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +51 -132
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/redis-cache-adapter/utilities.d.ts +13 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/utilities.js +69 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/utilities.js.map +1 -0
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts +29 -40
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +46 -55
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/derivables/_module-exports.d.ts +1 -1
- package/dist/cache/implementations/derivables/_module-exports.js +1 -1
- package/dist/cache/implementations/derivables/_module-exports.js.map +1 -1
- package/dist/cache/implementations/derivables/cache/_module.d.ts +1 -0
- package/dist/cache/implementations/derivables/cache/_module.js +1 -0
- package/dist/cache/implementations/derivables/cache/_module.js.map +1 -1
- package/dist/cache/implementations/derivables/cache/cache.d.ts +122 -565
- package/dist/cache/implementations/derivables/cache/cache.js +342 -854
- package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
- package/dist/cache/implementations/derivables/cache/database-cache-adapter.d.ts +21 -0
- package/dist/cache/implementations/derivables/cache/database-cache-adapter.js +110 -0
- package/dist/cache/implementations/derivables/cache/database-cache-adapter.js.map +1 -0
- package/dist/cache/implementations/derivables/cache/is-database-cache-adapter.d.ts +9 -0
- package/dist/cache/implementations/derivables/cache/is-database-cache-adapter.js +20 -0
- package/dist/cache/implementations/derivables/cache/is-database-cache-adapter.js.map +1 -0
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +65 -104
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js +101 -85
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
- package/dist/cache/implementations/test-utilities/_module-exports.d.ts +1 -0
- package/dist/cache/implementations/test-utilities/_module-exports.js +1 -0
- package/dist/cache/implementations/test-utilities/_module-exports.js.map +1 -1
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.d.ts +9 -11
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js +246 -247
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js.map +1 -1
- package/dist/cache/implementations/test-utilities/cache.test-suite.d.ts +16 -30
- package/dist/cache/implementations/test-utilities/cache.test-suite.js +271 -996
- package/dist/cache/implementations/test-utilities/cache.test-suite.js.map +1 -1
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.d.ts +60 -0
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js +698 -0
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js.map +1 -0
- package/dist/collection/contracts/async-collection.contract.d.ts +2 -3
- package/dist/collection/contracts/async-collection.contract.js +1 -12
- package/dist/collection/contracts/async-collection.contract.js.map +1 -1
- package/dist/collection/contracts/collection.contract.d.ts +1 -1
- package/dist/collection/contracts/collection.errors.d.ts +1 -1
- package/dist/collection/contracts/collection.errors.js +3 -6
- package/dist/collection/contracts/collection.errors.js.map +1 -1
- package/dist/collection/implementations/_shared.d.ts +4 -4
- package/dist/collection/implementations/_shared.js +6 -9
- package/dist/collection/implementations/_shared.js.map +1 -1
- package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.js +2 -2
- package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.js.map +1 -1
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +1 -1
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js +6 -5
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/collection/implementations/iterable-collection/iterable-collection.d.ts +1 -1
- package/dist/collection/implementations/iterable-collection/iterable-collection.js +1 -1
- package/dist/collection/implementations/list-collection/list-collection.d.ts +1 -1
- package/dist/collection/implementations/list-collection/list-collection.js +1 -1
- package/dist/event-bus/contracts/event-bus-adapter.contract.d.ts +0 -9
- package/dist/event-bus/contracts/event-bus.contract.d.ts +5 -5
- package/dist/event-bus/contracts/event-bus.contract.js.map +1 -1
- package/dist/event-bus/contracts/event-bus.errors.js +2 -5
- package/dist/event-bus/contracts/event-bus.errors.js.map +1 -1
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.d.ts +9 -29
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js +14 -35
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js.map +1 -1
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.d.ts +1 -3
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js +1 -7
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js.map +1 -1
- package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.d.ts +8 -15
- package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js +15 -34
- package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js.map +1 -1
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +78 -267
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +119 -323
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
- package/dist/event-bus/implementations/derivables/event-bus/listener-store.d.ts +13 -0
- package/dist/event-bus/implementations/derivables/event-bus/listener-store.js +42 -0
- package/dist/event-bus/implementations/derivables/event-bus/listener-store.js.map +1 -0
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +70 -96
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +100 -90
- 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-adapter.test-suite.d.ts +2 -48
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js +31 -122
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js.map +1 -1
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.d.ts +2 -50
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js +41 -89
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js.map +1 -1
- package/dist/lock/contracts/database-lock-adapter.contract.d.ts +0 -9
- package/dist/lock/contracts/lock-adapter.contract.d.ts +0 -9
- package/dist/lock/contracts/lock-provider.contract.d.ts +1 -1
- package/dist/lock/contracts/lock.errors.js +2 -5
- package/dist/lock/contracts/lock.errors.js.map +1 -1
- package/dist/lock/contracts/lock.events.js +2 -5
- package/dist/lock/contracts/lock.events.js.map +1 -1
- package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.d.ts +0 -5
- package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js +2 -21
- package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.d.ts +11 -16
- package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js +11 -20
- package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.d.ts +7 -26
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js +7 -35
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.d.ts +13 -20
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js +13 -37
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.d.ts +4 -22
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js +4 -31
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.d.ts +12 -17
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js +12 -21
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.d.ts +0 -2
- package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.js +2 -8
- package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.d.ts +9 -0
- package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.js +17 -0
- package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.js.map +1 -0
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +115 -372
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +197 -455
- 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 +15 -17
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js +42 -40
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-state.d.ts +3 -3
- package/dist/lock/implementations/derivables/lock-provider/lock-state.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +30 -754
- package/dist/lock/implementations/derivables/lock-provider/lock.js +94 -812
- 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 +58 -161
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js +116 -122
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.d.ts +4 -5
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js +172 -247
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js.map +1 -1
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.d.ts +5 -8
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js +93 -98
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js.map +1 -1
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.d.ts +15 -20
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +133 -137
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
- package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js +1 -2
- package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js.map +1 -1
- package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.d.ts +2 -2
- package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.js +1 -1
- package/dist/serde/implementations/adapters/redis-serde/redis-serde.js +1 -2
- package/dist/serde/implementations/adapters/redis-serde/redis-serde.js.map +1 -1
- package/dist/serde/implementations/adapters/sql-serde/sql-serde.js +1 -2
- package/dist/serde/implementations/adapters/sql-serde/sql-serde.js.map +1 -1
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.d.ts +2 -2
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js +2 -2
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js.map +1 -1
- package/dist/serde/implementations/derivables/serde.d.ts +14 -14
- package/dist/serde/implementations/derivables/serde.js +14 -15
- package/dist/serde/implementations/derivables/serde.js.map +1 -1
- package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.d.ts +4 -4
- package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.js +3 -3
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.d.ts +5 -5
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js +4 -4
- package/dist/utilities/_module-exports.d.ts +1 -2
- package/dist/utilities/_module-exports.js +1 -2
- package/dist/utilities/_module-exports.js.map +1 -1
- package/dist/utilities/classes/_module.d.ts +4 -0
- package/dist/utilities/classes/_module.js +5 -0
- package/dist/utilities/classes/_module.js.map +1 -0
- package/dist/utilities/classes/key-prefixer/_module.d.ts +2 -0
- package/dist/utilities/classes/key-prefixer/_module.js +3 -0
- package/dist/utilities/classes/key-prefixer/_module.js.map +1 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.contract.d.ts +28 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.contract.js +5 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.contract.js.map +1 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.d.ts +73 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.js +135 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.js.map +1 -0
- package/dist/utilities/classes/kysely-table-name-transformer-plugin/_module.d.ts +1 -0
- package/dist/utilities/classes/kysely-table-name-transformer-plugin/_module.js +2 -0
- package/dist/utilities/classes/kysely-table-name-transformer-plugin/_module.js.map +1 -0
- package/dist/utilities/classes/kysely-table-name-transformer-plugin/kysely-table-name-transformer-plugin.js.map +1 -0
- package/dist/utilities/classes/pipeline/_module.d.ts +1 -0
- package/dist/utilities/classes/pipeline/_module.js +2 -0
- package/dist/utilities/classes/pipeline/_module.js.map +1 -0
- package/dist/utilities/{pipeline → classes/pipeline}/pipeline.d.ts +3 -2
- package/dist/utilities/{pipeline → classes/pipeline}/pipeline.js +3 -2
- package/dist/utilities/classes/pipeline/pipeline.js.map +1 -0
- package/dist/utilities/classes/time-span/_module.d.ts +1 -0
- package/dist/utilities/classes/time-span/_module.js +2 -0
- package/dist/utilities/classes/time-span/_module.js.map +1 -0
- package/dist/utilities/{time-span → classes/time-span}/time-span.d.ts +2 -1
- package/dist/utilities/{time-span → classes/time-span}/time-span.js +1 -0
- package/dist/utilities/classes/time-span/time-span.js.map +1 -0
- package/dist/utilities/contracts/_module.d.ts +2 -1
- package/dist/utilities/contracts/_module.js +2 -1
- package/dist/utilities/contracts/_module.js.map +1 -1
- package/dist/utilities/contracts/prunable.contract.d.ts +11 -0
- package/dist/utilities/contracts/prunable.contract.js +5 -0
- package/dist/utilities/contracts/prunable.contract.js.map +1 -0
- package/dist/utilities/functions.d.ts +30 -2
- package/dist/utilities/functions.js +66 -4
- package/dist/utilities/functions.js.map +1 -1
- package/dist/utilities/types.d.ts +47 -14
- package/package.json +14 -13
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/_module.js +0 -2
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/_module.js.map +0 -1
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.d.ts +0 -61
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js +0 -318
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js.map +0 -1
- package/dist/cache/implementations/adapters/no-op-cache-adapter/_module.d.ts +0 -1
- package/dist/cache/implementations/adapters/no-op-cache-adapter/_module.js +0 -2
- package/dist/cache/implementations/adapters/no-op-cache-adapter/_module.js.map +0 -1
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.d.ts +0 -22
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js +0 -39
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js.map +0 -1
- package/dist/utilities/kysely/_module.d.ts +0 -1
- package/dist/utilities/kysely/_module.js +0 -2
- package/dist/utilities/kysely/_module.js.map +0 -1
- package/dist/utilities/kysely/kysely-table-name-transformer-plugin.js.map +0 -1
- package/dist/utilities/pipeline/_module.d.ts +0 -1
- package/dist/utilities/pipeline/_module.js +0 -2
- package/dist/utilities/pipeline/_module.js.map +0 -1
- package/dist/utilities/pipeline/pipeline.js.map +0 -1
- package/dist/utilities/time-span/_module.d.ts +0 -1
- package/dist/utilities/time-span/_module.js +0 -2
- package/dist/utilities/time-span/_module.js.map +0 -1
- package/dist/utilities/time-span/time-span.js.map +0 -1
- /package/dist/utilities/{kysely → classes/kysely-table-name-transformer-plugin}/kysely-table-name-transformer-plugin.d.ts +0 -0
- /package/dist/utilities/{kysely → classes/kysely-table-name-transformer-plugin}/kysely-table-name-transformer-plugin.js +0 -0
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Cache
|
|
3
3
|
*/
|
|
4
|
-
import type { CacheEvents,
|
|
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
6
|
import { type IGroupableCache } from "../../../../cache/contracts/_module-exports.js";
|
|
7
|
-
import type
|
|
8
|
-
import type
|
|
7
|
+
import { type AsyncLazyable, type Invokable, type OneOrMore } from "../../../../utilities/_module-exports.js";
|
|
8
|
+
import { type NoneFunction, type TimeSpan, type Factoryable } from "../../../../utilities/_module-exports.js";
|
|
9
9
|
import type { BackoffPolicy, RetryPolicy } from "../../../../async/_module-exports.js";
|
|
10
10
|
import { LazyPromise } from "../../../../async/_module-exports.js";
|
|
11
11
|
import type { IGroupableEventBus, Unsubscribe, EventClass, EventInstance } from "../../../../event-bus/contracts/_module-exports.js";
|
|
12
|
+
import type { IKeyPrefixer, Items } from "../../../../utilities/_module-exports.js";
|
|
12
13
|
/**
|
|
13
14
|
*
|
|
14
|
-
* IMPORT_PATH: ```"@daiso-tech/core/cache
|
|
15
|
+
* IMPORT_PATH: ```"@daiso-tech/core/cache"```
|
|
15
16
|
* @group Derivables
|
|
16
17
|
*/
|
|
17
|
-
export type
|
|
18
|
-
|
|
18
|
+
export type CacheSettingsBase = {
|
|
19
|
+
keyPrefixer: IKeyPrefixer;
|
|
19
20
|
/**
|
|
20
21
|
* @default
|
|
21
22
|
* ```ts
|
|
23
|
+
* import { EventBus } from "@daiso-tech/core/event-bus";
|
|
24
|
+
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
25
|
+
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
26
|
+
*
|
|
22
27
|
* new EventBus({
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* })
|
|
28
|
+
* keyPrefixer: new KeyPrefixer("event-bus"),
|
|
29
|
+
* adapter: new MemoryEventBusAdapter()
|
|
26
30
|
* })
|
|
27
31
|
* ```
|
|
28
32
|
*/
|
|
@@ -54,597 +58,150 @@ export type CacheSettings = {
|
|
|
54
58
|
timeout?: TimeSpan | null;
|
|
55
59
|
};
|
|
56
60
|
/**
|
|
57
|
-
* <i>Cache</i> class can be derived from any <i>{@link ICacheAdapter}</i>.
|
|
58
61
|
*
|
|
59
|
-
* IMPORT_PATH: ```"@daiso-tech/core/cache
|
|
62
|
+
* IMPORT_PATH: ```"@daiso-tech/core/cache"```
|
|
63
|
+
* @group Derivables
|
|
64
|
+
*/
|
|
65
|
+
export type CacheAdapterFactoryable<TType> = Factoryable<string, ICacheAdapter<TType> | IDatabaseCacheAdapter<TType>>;
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* IMPORT_PATH: ```"@daiso-tech/core/cache"```
|
|
69
|
+
* @group Derivables
|
|
70
|
+
*/
|
|
71
|
+
export type CacheSettings = CacheSettingsBase & {
|
|
72
|
+
adapter: CacheAdapterFactoryable<any>;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
*
|
|
76
|
+
* IMPORT_PATH: ```"@daiso-tech/core/cache"```
|
|
60
77
|
* @group Derivables
|
|
61
78
|
*/
|
|
62
79
|
export declare class Cache<TType = unknown> implements IGroupableCache<TType> {
|
|
80
|
+
private static resolveCacheAdapter;
|
|
81
|
+
private static resolveCacheAdapterFactoryable;
|
|
63
82
|
private static defaultRetryPolicy;
|
|
64
83
|
private readonly groupdEventBus;
|
|
65
84
|
private readonly eventBus;
|
|
66
|
-
private readonly
|
|
85
|
+
private readonly adapterFactoryable;
|
|
86
|
+
private readonly adapterPromise;
|
|
67
87
|
private readonly defaultTtl;
|
|
68
88
|
private readonly retryAttempts;
|
|
69
89
|
private readonly backoffPolicy;
|
|
70
90
|
private readonly retryPolicy;
|
|
71
91
|
private readonly timeout;
|
|
92
|
+
private readonly keyPrefixer;
|
|
72
93
|
/**
|
|
73
|
-
* @example
|
|
74
|
-
* ```ts
|
|
75
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
76
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
77
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
78
94
|
*
|
|
79
|
-
* const cache: IGroupableCache = new Cache({
|
|
80
|
-
* adapter: new MemoryCacheAdapter({
|
|
81
|
-
* rootGroup: "@global"
|
|
82
|
-
* }),
|
|
83
|
-
* });
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
constructor(settings: CacheSettings);
|
|
87
|
-
private createLayPromise;
|
|
88
|
-
/**
|
|
89
|
-
* You can listen to different events of <i>Cache</i> class instance.
|
|
90
|
-
*
|
|
91
|
-
* Refer to <i>{@link CacheEvents}</i>, to se all events dispatched by <i>Cache</i> class instance.
|
|
92
|
-
* Refer to <i>{@link IEventListenable}</i> for details on how the method works.
|
|
93
95
|
* @example
|
|
94
96
|
* ```ts
|
|
95
|
-
* import
|
|
96
|
-
* import
|
|
97
|
-
* import {
|
|
98
|
-
* import
|
|
99
|
-
* import
|
|
100
|
-
* import {
|
|
97
|
+
* import { SqliteCacheAdapter } from "@daiso-tech/core/cache/adapters";
|
|
98
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
99
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
|
|
100
|
+
* import Sqlite from "better-sqlite3";
|
|
101
|
+
* import { Cache } from "@daiso-tech/core/cache";
|
|
102
|
+
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
101
103
|
*
|
|
102
|
-
* const
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
104
|
+
* const database = new Sqlite("local.db");
|
|
105
|
+
* const serde = new Serde(new SuperJsonSerdeAdapter());
|
|
106
|
+
* const cacheAdapter = new SqliteCacheAdapter({
|
|
107
|
+
* database,
|
|
108
|
+
* serde,
|
|
106
109
|
* });
|
|
110
|
+
* // You need initialize the adapter once before using it.
|
|
111
|
+
* await cacheAdapter.init();
|
|
107
112
|
*
|
|
108
|
-
* const
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* await cache.addListener(KeyAddedCacheEvent, listener);
|
|
112
|
-
* await cache.add("a", 1);
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
|
-
addListener<TEventClass extends EventClass<CacheEvents>>(eventName: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
116
|
-
/**
|
|
117
|
-
* You can listen to different events of <i>Cache</i> class instance.
|
|
118
|
-
*
|
|
119
|
-
* Refer to <i>{@link CacheEvents}</i>, to se all events dispatched by <i>Cache</i> class instance.
|
|
120
|
-
* Refer to <i>{@link IEventListenable}</i> for details on how the method works.
|
|
121
|
-
* @example
|
|
122
|
-
* ```ts
|
|
123
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
124
|
-
* import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
|
|
125
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
126
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
127
|
-
* import type { Invokable} from "@daiso-tech/core/event-bus/contracts";
|
|
128
|
-
* import type { Invokable} from "@daiso-tech/core/event-bus/contracts";
|
|
129
|
-
* import { KeyAddedCacheEvent, type CacheEvents } from "@daiso-tech/core/cache/contracts";
|
|
130
|
-
*
|
|
131
|
-
* const cache: IGroupableCache = new Cache({
|
|
132
|
-
* adapter: new MemoryCacheAdapter({
|
|
133
|
-
* rootGroup: "@global"
|
|
134
|
-
* }),
|
|
113
|
+
* const cache = new Cache({
|
|
114
|
+
* keyPrefixer: new KeyPrefixer("cache"),
|
|
115
|
+
* adapter: cacheAdapter,
|
|
135
116
|
* });
|
|
136
|
-
*
|
|
137
|
-
* const listener: Invokable<CacheEvents> = event => {
|
|
138
|
-
* console.log(event);
|
|
139
|
-
* };
|
|
140
|
-
* await cache.addListenerMany([KeyAddedCacheEvent], listener);
|
|
141
|
-
* await cache.add("a", 1);
|
|
142
|
-
* ```
|
|
143
|
-
*/
|
|
144
|
-
addListenerMany<TEventClass extends EventClass<CacheEvents>>(eventNames: TEventClass[], listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
145
|
-
/**
|
|
146
|
-
* You can listen to different events of <i>Cache</i> class instance.
|
|
147
|
-
*
|
|
148
|
-
* Refer to <i>{@link CacheEvents}</i>, to se all events dispatched by <i>Cache</i> class instance.
|
|
149
|
-
* Refer to <i>{@link IEventListenable}</i> for details on how the method works.
|
|
150
|
-
* @example
|
|
151
|
-
* ```ts
|
|
152
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
153
|
-
* import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
|
|
154
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
155
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
156
|
-
* import type { Invokable} from "@daiso-tech/core/event-bus/contracts";
|
|
157
|
-
* import { KeyAddedCacheEvent, type CacheEvents } from "@daiso-tech/core/cache/contracts";
|
|
158
|
-
*
|
|
159
|
-
* const cache: IGroupableCache = new Cache({
|
|
160
|
-
* adapter: new MemoryCacheAdapter({
|
|
161
|
-
* rootGroup: "@global"
|
|
162
|
-
* }),
|
|
163
|
-
* });
|
|
164
|
-
*
|
|
165
|
-
* const listener: Invokable<CacheEvents> = event => {
|
|
166
|
-
* console.log(event);
|
|
167
|
-
* };
|
|
168
|
-
* await cache.addListener(KeyAddedCacheEvent, listener);
|
|
169
|
-
* await cache.removeListener(KeyAddedCacheEvent, listener);
|
|
170
|
-
* await cache.add("a", 1);
|
|
171
117
|
* ```
|
|
172
|
-
*/
|
|
173
|
-
removeListener<TEventClass extends EventClass<CacheEvents>>(eventName: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
174
|
-
/**
|
|
175
|
-
* You can listen to different events of <i>Cache</i> class instance.
|
|
176
118
|
*
|
|
177
|
-
*
|
|
178
|
-
* Refer to <i>{@link IEventListenable}</i> for details on how the method works.
|
|
119
|
+
* You can pass factory function that will create an adapter for every group.
|
|
179
120
|
* @example
|
|
180
121
|
* ```ts
|
|
181
|
-
* import
|
|
182
|
-
* import type {
|
|
183
|
-
* import {
|
|
184
|
-
* import {
|
|
185
|
-
* import
|
|
186
|
-
* import {
|
|
122
|
+
* import { SqliteCacheAdapter } from "@daiso-tech/core/cache/adapters";
|
|
123
|
+
* import type { ICacheAdapter } from "@daiso-tech/core/cache/contracts";
|
|
124
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
125
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
|
|
126
|
+
* import Sqlite from "better-sqlite3";
|
|
127
|
+
* import { Cache } from "@daiso-tech/core/cache";
|
|
128
|
+
* import { KeyPrefixer, type Promiseable } from "@daiso-tech/core/utilities";
|
|
187
129
|
*
|
|
188
|
-
* const cache: IGroupableCache = new Cache({
|
|
189
|
-
* adapter: new MemoryCacheAdapter({
|
|
190
|
-
* rootGroup: "@global"
|
|
191
|
-
* }),
|
|
192
|
-
* });
|
|
193
|
-
*
|
|
194
|
-
* const listener: Invokable<CacheEvents> = event => {
|
|
195
|
-
* console.log(event);
|
|
196
|
-
* };
|
|
197
|
-
* await cache.addListenerMany([KeyAddedCacheEvent], listener);
|
|
198
|
-
* await cache.removeListenerMany(KeyAddedCacheEvent, listener);
|
|
199
|
-
* await cache.add("a", 1);
|
|
200
|
-
* ```
|
|
201
|
-
*/
|
|
202
|
-
removeListenerMany<TEventClass extends EventClass<CacheEvents>>(eventNames: TEventClass[], listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
203
|
-
/**
|
|
204
|
-
* You can listen to different events of <i>Cache</i> class instance.
|
|
205
130
|
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
131
|
+
* async function cahceAdapterFactory(prefix: string): Promiseable<ICacheAdapter> {
|
|
132
|
+
* const database = new Sqlite("local.db");
|
|
133
|
+
* const serde = new Serde(new SuperJsonSerdeAdapter());
|
|
134
|
+
* const cacheAdapter = new SqliteCacheAdapter({
|
|
135
|
+
* database,
|
|
136
|
+
* serde,
|
|
137
|
+
* tableName: `cache_${prefix}`
|
|
138
|
+
* });
|
|
139
|
+
* await cacheAdapter.init();
|
|
140
|
+
* return cacheAdapter;
|
|
141
|
+
* }
|
|
216
142
|
*
|
|
217
|
-
* const cache
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
* }),
|
|
143
|
+
* const cache = new Cache({
|
|
144
|
+
* keyPrefixer: new KeyPrefixer("cache"),
|
|
145
|
+
* adapter: cahceAdapterFactory,
|
|
221
146
|
* });
|
|
222
|
-
*
|
|
223
|
-
* const listener: Invokable<CacheEvents> = event => {
|
|
224
|
-
* console.log(event);
|
|
225
|
-
* };
|
|
226
|
-
* await cache.listenOnce(KeyAddedCacheEvent, listener);
|
|
227
|
-
* await cache.add("a", 1);
|
|
228
147
|
* ```
|
|
229
|
-
*/
|
|
230
|
-
listenOnce<TEventClass extends EventClass<CacheEvents>>(eventName: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
231
|
-
asPromise<TEventClass extends EventClass<CacheEvents>>(event: TEventClass): LazyPromise<EventInstance<TEventClass>>;
|
|
232
|
-
/**
|
|
233
|
-
* You can listen to different events of <i>Cache</i> class instance.
|
|
234
148
|
*
|
|
235
|
-
*
|
|
236
|
-
* Refer to <i>{@link IEventListenable}</i> for details on how the method works.
|
|
149
|
+
* You can also pass factory object that implements <i>{@link IFactoryObject}</i> contract. This useful for depedency injection libraries.
|
|
237
150
|
* @example
|
|
238
151
|
* ```ts
|
|
239
|
-
* import
|
|
240
|
-
* import type {
|
|
241
|
-
* import {
|
|
242
|
-
* import {
|
|
243
|
-
* import
|
|
244
|
-
* import {
|
|
152
|
+
* import { SqliteCacheAdapter } from "@daiso-tech/core/cache/adapters";
|
|
153
|
+
* import type { ICacheAdapter } from "@daiso-tech/core/cache/contracts";
|
|
154
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
155
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
|
|
156
|
+
* import Sqlite from "better-sqlite3";
|
|
157
|
+
* import { Cache } from "@daiso-tech/core/cache";
|
|
158
|
+
* import { KeyPrefixer, type IFactoryObject, type Promiseable } from "@daiso-tech/core/utilities";
|
|
245
159
|
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
160
|
+
* class CahceAdapterFactory implements IFactoryObject<string, ICacheAdapter> {
|
|
161
|
+
* async use(prefix: string): Promiseable<ICacheAdapter> {
|
|
162
|
+
* const database = new Sqlite("local.db");
|
|
163
|
+
* const serde = new Serde(new SuperJsonSerdeAdapter());
|
|
164
|
+
* const cacheAdapter = new SqliteCacheAdapter({
|
|
165
|
+
* database,
|
|
166
|
+
* serde,
|
|
167
|
+
* tableName: `cache_${prefix}`
|
|
168
|
+
* });
|
|
169
|
+
* await cacheAdapter.init();
|
|
170
|
+
* return cacheAdapter;
|
|
171
|
+
* }
|
|
172
|
+
* }
|
|
173
|
+
* const cahceAdapterFactory = new CahceAdapterFactory();
|
|
174
|
+
* const cache = new Cache({
|
|
175
|
+
* keyPrefixer: new KeyPrefixer("cache"),
|
|
176
|
+
* adapter: cahceAdapterFactory,
|
|
250
177
|
* });
|
|
251
|
-
*
|
|
252
|
-
* const listener: Invokable<CacheEvents> = event => {
|
|
253
|
-
* console.log(event);
|
|
254
|
-
* };
|
|
255
|
-
* const unsubscribe = await cache.subscribe(KeyAddedCacheEvent, listener);
|
|
256
|
-
* await cache.add("a", 1);
|
|
257
|
-
* await unsubscribe();
|
|
258
178
|
* ```
|
|
259
179
|
*/
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
* const unsubscribe = await cache.subscribeMany([KeyAddedCacheEvent], listener);
|
|
285
|
-
* await cache.add("a", 1);
|
|
286
|
-
* await unsubscribe();
|
|
287
|
-
* ```
|
|
288
|
-
*/
|
|
289
|
-
subscribeMany<TEventClass extends EventClass<CacheEvents>>(eventNames: TEventClass[], listener: Invokable<EventInstance<TEventClass>>): LazyPromise<Unsubscribe>;
|
|
290
|
-
/**
|
|
291
|
-
* @example
|
|
292
|
-
* ```ts
|
|
293
|
-
* import type { IGroupableCache, ICache } from "@daiso-tech/core/cache/contracts";
|
|
294
|
-
* import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
|
|
295
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
296
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
297
|
-
*
|
|
298
|
-
* const cache: IGroupableCache = new Cache({
|
|
299
|
-
* adapter: new MemoryCacheAdapter({
|
|
300
|
-
* rootGroup: "@global"
|
|
301
|
-
* }),
|
|
302
|
-
* });
|
|
303
|
-
*
|
|
304
|
-
* // Will print "@global"
|
|
305
|
-
* console.log(cache.getGroup());
|
|
306
|
-
*
|
|
307
|
-
* const groupedCache: ICache = cache.withGroup("company-1");
|
|
308
|
-
*
|
|
309
|
-
* // Will print "@global/company-1"
|
|
310
|
-
* console.log(groupedCache.getGroup());
|
|
311
|
-
* ```
|
|
312
|
-
*/
|
|
313
|
-
withGroup(group: OneOrMore<string>): ICache<TType>;
|
|
314
|
-
/**
|
|
315
|
-
* @example
|
|
316
|
-
* ```ts
|
|
317
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
318
|
-
* import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
|
|
319
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
320
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
321
|
-
*
|
|
322
|
-
* const cache: IGroupableCache = new Cache({
|
|
323
|
-
* adapter: new MemoryCacheAdapter({
|
|
324
|
-
* rootGroup: "@global"
|
|
325
|
-
* }),
|
|
326
|
-
* });
|
|
327
|
-
*
|
|
328
|
-
* // Will print "@global"
|
|
329
|
-
* console.log(cache.getGroup());
|
|
330
|
-
* ```
|
|
331
|
-
*/
|
|
332
|
-
getGroup(): string;
|
|
333
|
-
get(key: string): LazyPromise<TType | null>;
|
|
334
|
-
add(key: string, value: TType,
|
|
335
|
-
/**
|
|
336
|
-
* @default null
|
|
337
|
-
*/
|
|
338
|
-
ttl?: TimeSpan | null): LazyPromise<boolean>;
|
|
339
|
-
update(key: string, value: TType): LazyPromise<boolean>;
|
|
340
|
-
put(key: string, value: TType,
|
|
341
|
-
/**
|
|
342
|
-
* @default null
|
|
343
|
-
*/
|
|
344
|
-
ttl?: TimeSpan | null): LazyPromise<boolean>;
|
|
345
|
-
remove(key: string): LazyPromise<boolean>;
|
|
346
|
-
increment(key: string, value?: Extract<TType, number>): LazyPromise<boolean>;
|
|
180
|
+
constructor(settings: CacheSettings);
|
|
181
|
+
addListener<TEventClass extends EventClass<CacheEvents<TType>>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
182
|
+
addListenerMany<TEventClassArr extends EventClass<CacheEvents<TType>>[]>(events: [...TEventClassArr], listener: Invokable<EventInstance<Items<TEventClassArr>>>): LazyPromise<void>;
|
|
183
|
+
removeListener<TEventClass extends EventClass<CacheEvents<TType>>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
184
|
+
removeListenerMany<TEventClassArr extends EventClass<CacheEvents<TType>>[]>(events: [...TEventClassArr], listener: Invokable<EventInstance<Items<TEventClassArr>>>): LazyPromise<void>;
|
|
185
|
+
listenOnce<TEventClass extends EventClass<CacheEvents<TType>>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
186
|
+
asPromise<TEventClass extends EventClass<CacheEvents<TType>>>(event: TEventClass): LazyPromise<EventInstance<TEventClass>>;
|
|
187
|
+
subscribe<TEventClass extends EventClass<CacheEvents<TType>>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<Unsubscribe>;
|
|
188
|
+
subscribeMany<TEventClassArr extends EventClass<CacheEvents<TType>>[]>(events: [...TEventClassArr], listener: Invokable<EventInstance<Items<TEventClassArr>>>): LazyPromise<Unsubscribe>;
|
|
189
|
+
private createLazyPromise;
|
|
190
|
+
exists(key: OneOrMore<string>): LazyPromise<boolean>;
|
|
191
|
+
missing(key: OneOrMore<string>): LazyPromise<boolean>;
|
|
192
|
+
get(key: OneOrMore<string>): LazyPromise<TType | null>;
|
|
193
|
+
getOrFail(key: OneOrMore<string>): LazyPromise<TType>;
|
|
194
|
+
getAndRemove(key: OneOrMore<string>): LazyPromise<TType | null>;
|
|
195
|
+
getOr(key: OneOrMore<string>, defaultValue: AsyncLazyable<NoneFunction<TType>>): LazyPromise<TType>;
|
|
196
|
+
getOrAdd(key: OneOrMore<string>, valueToAdd: AsyncLazyable<NoneFunction<TType>>, ttl?: TimeSpan | null): LazyPromise<TType>;
|
|
197
|
+
add(key: OneOrMore<string>, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
|
|
198
|
+
put(key: OneOrMore<string>, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
|
|
199
|
+
update(key: OneOrMore<string>, value: TType): LazyPromise<boolean>;
|
|
200
|
+
increment(key: OneOrMore<string>, value?: Extract<TType, number>): LazyPromise<boolean>;
|
|
201
|
+
decrement(key: OneOrMore<string>, value?: Extract<TType, number>): LazyPromise<boolean>;
|
|
202
|
+
remove(key: OneOrMore<string>): LazyPromise<boolean>;
|
|
203
|
+
removeMany(keys: OneOrMore<string>[]): LazyPromise<boolean>;
|
|
347
204
|
clear(): LazyPromise<void>;
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
missing(key: string): LazyPromise<boolean>;
|
|
351
|
-
missingMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
|
|
352
|
-
getMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, TType | null>>;
|
|
353
|
-
/**
|
|
354
|
-
* @example
|
|
355
|
-
* ```ts
|
|
356
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
357
|
-
* import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
|
|
358
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
359
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
360
|
-
*
|
|
361
|
-
* const cache: IGroupableCache = new Cache({
|
|
362
|
-
* adapter: new MemoryCacheAdapter({
|
|
363
|
-
* rootGroup: "@global"
|
|
364
|
-
* }),
|
|
365
|
-
* });
|
|
366
|
-
*
|
|
367
|
-
* const result = await cache.getOr("a", -1);
|
|
368
|
-
* // -1
|
|
369
|
-
* console.log(result);
|
|
370
|
-
* ```
|
|
371
|
-
*
|
|
372
|
-
* You can pass function as default value.
|
|
373
|
-
* @example
|
|
374
|
-
* ```ts
|
|
375
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
376
|
-
* import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
|
|
377
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
378
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
379
|
-
*
|
|
380
|
-
* const cache: IGroupableCache = new Cache({
|
|
381
|
-
* adapter: new MemoryCacheAdapter({
|
|
382
|
-
* rootGroup: "@global"
|
|
383
|
-
* }),
|
|
384
|
-
* });
|
|
385
|
-
*
|
|
386
|
-
* const result = await cache.getOr("a", () => -1);
|
|
387
|
-
* // -1
|
|
388
|
-
* console.log(result);
|
|
389
|
-
* ```
|
|
390
|
-
*
|
|
391
|
-
* You can pass async function as default value.
|
|
392
|
-
* @example
|
|
393
|
-
* ```ts
|
|
394
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
395
|
-
* import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
|
|
396
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
397
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
398
|
-
*
|
|
399
|
-
* const cache: IGroupableCache = new Cache({
|
|
400
|
-
* adapter: new MemoryCacheAdapter({
|
|
401
|
-
* rootGroup: "@global"
|
|
402
|
-
* }),
|
|
403
|
-
* });
|
|
404
|
-
*
|
|
405
|
-
* const result = await cache.getOr("a", async () => -1);
|
|
406
|
-
* // -1
|
|
407
|
-
* console.log(result);
|
|
408
|
-
* ```
|
|
409
|
-
*
|
|
410
|
-
* You can pass <i>{@link LazyPromise}</i> as default value.
|
|
411
|
-
* @example
|
|
412
|
-
* ```ts
|
|
413
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
414
|
-
* import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
|
|
415
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
416
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
417
|
-
*
|
|
418
|
-
* const cache: IGroupableCache = new Cache({
|
|
419
|
-
* adapter: new MemoryCacheAdapter({
|
|
420
|
-
* rootGroup: "@global"
|
|
421
|
-
* }),
|
|
422
|
-
* });
|
|
423
|
-
*
|
|
424
|
-
* const result = await cache.getOr("a", new LazyPromise(async () => -1));
|
|
425
|
-
* // -1
|
|
426
|
-
* console.log(result);
|
|
427
|
-
* ```
|
|
428
|
-
*/
|
|
429
|
-
getOr(key: string, defaultValue: AsyncLazyable<TType>): LazyPromise<TType>;
|
|
430
|
-
/**
|
|
431
|
-
* @example
|
|
432
|
-
* ```ts
|
|
433
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
434
|
-
* import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
|
|
435
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
436
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
437
|
-
*
|
|
438
|
-
* const cache: IGroupableCache = new Cache({
|
|
439
|
-
* adapter: new MemoryCacheAdapter({
|
|
440
|
-
* rootGroup: "@global"
|
|
441
|
-
* }),
|
|
442
|
-
* });
|
|
443
|
-
*
|
|
444
|
-
* const result = await cache.getOrMany({ a: -1 });
|
|
445
|
-
* // { a: -1 }
|
|
446
|
-
* console.log(result);
|
|
447
|
-
* ```
|
|
448
|
-
*
|
|
449
|
-
* You can pass function as default value.
|
|
450
|
-
* @example
|
|
451
|
-
* ```ts
|
|
452
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
453
|
-
* import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
|
|
454
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
455
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
456
|
-
*
|
|
457
|
-
* const cache: IGroupableCache = new Cache({
|
|
458
|
-
* adapter: new MemoryCacheAdapter({
|
|
459
|
-
* rootGroup: "@global"
|
|
460
|
-
* }),
|
|
461
|
-
* });
|
|
462
|
-
*
|
|
463
|
-
* const result = await cache.getOrMany({ a: () => -1 });
|
|
464
|
-
* // { a: -1 }
|
|
465
|
-
* console.log(result);
|
|
466
|
-
* ```
|
|
467
|
-
*
|
|
468
|
-
* You can pass async function as default value.
|
|
469
|
-
* @example
|
|
470
|
-
* ```ts
|
|
471
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
472
|
-
* import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
|
|
473
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
474
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
475
|
-
*
|
|
476
|
-
* const cache: IGroupableCache = new Cache({
|
|
477
|
-
* adapter: new MemoryCacheAdapter({
|
|
478
|
-
* rootGroup: "@global"
|
|
479
|
-
* }),
|
|
480
|
-
* });
|
|
481
|
-
*
|
|
482
|
-
* const result = await cache.getOrMany({ a: async () => -1 });
|
|
483
|
-
* // { a: -1 }
|
|
484
|
-
* console.log(result);
|
|
485
|
-
* ```
|
|
486
|
-
*
|
|
487
|
-
* You can pass <i>{@link LazyPromise}</i> as default value.
|
|
488
|
-
* @example
|
|
489
|
-
* ```ts
|
|
490
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
491
|
-
* import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
|
|
492
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
493
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
494
|
-
*
|
|
495
|
-
* const cache: IGroupableCache = new Cache({
|
|
496
|
-
* adapter: new MemoryCacheAdapter({
|
|
497
|
-
* rootGroup: "@global"
|
|
498
|
-
* }),
|
|
499
|
-
* });
|
|
500
|
-
*
|
|
501
|
-
* const result = await cache.getOrMany({ a: new LazyPromise(async () => - 1) });
|
|
502
|
-
* // { a: -1 }
|
|
503
|
-
* console.log(result);
|
|
504
|
-
* ```
|
|
505
|
-
*/
|
|
506
|
-
getOrMany<TKeys extends string>(keysWithDefaults: Record<TKeys, AsyncLazyable<TType>>): LazyPromise<Record<TKeys, TType>>;
|
|
507
|
-
/**
|
|
508
|
-
* @example
|
|
509
|
-
* ```ts
|
|
510
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
511
|
-
* import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
|
|
512
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
513
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
514
|
-
*
|
|
515
|
-
* const cache: IGroupableCache = new Cache({
|
|
516
|
-
* adapter: new MemoryCacheAdapter({
|
|
517
|
-
* rootGroup: "@global"
|
|
518
|
-
* }),
|
|
519
|
-
* });
|
|
520
|
-
*
|
|
521
|
-
* await cache.add("a", 1);
|
|
522
|
-
*
|
|
523
|
-
* const result1 = await cache.getOrFail("a");
|
|
524
|
-
* // Will print 1
|
|
525
|
-
* console.log(result1);
|
|
526
|
-
*
|
|
527
|
-
* await cache.remove("a");
|
|
528
|
-
*
|
|
529
|
-
* // Will throw an error
|
|
530
|
-
* await cache.getOrFail("a");
|
|
531
|
-
* ```
|
|
532
|
-
*/
|
|
533
|
-
getOrFail(key: string): LazyPromise<TType>;
|
|
534
|
-
addMany<TKeys extends string>(values: Record<TKeys, WithTtlValue<TType>>): LazyPromise<Record<TKeys, boolean>>;
|
|
535
|
-
updateMany<TKeys extends string>(values: Record<TKeys, TType>): LazyPromise<Record<TKeys, boolean>>;
|
|
536
|
-
putMany<TKeys extends string>(values: Record<TKeys, WithTtlValue<TType>>): LazyPromise<Record<TKeys, boolean>>;
|
|
537
|
-
removeMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
|
|
538
|
-
/**
|
|
539
|
-
* @example
|
|
540
|
-
* ```ts
|
|
541
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
542
|
-
* import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
|
|
543
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
544
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
545
|
-
*
|
|
546
|
-
* const cache: IGroupableCache = new Cache({
|
|
547
|
-
* adapter: new MemoryCacheAdapter({
|
|
548
|
-
* rootGroup: "@global"
|
|
549
|
-
* }),
|
|
550
|
-
* });
|
|
551
|
-
*
|
|
552
|
-
* const result1 = await cache.getAndRemove("a");
|
|
553
|
-
* // Will print null
|
|
554
|
-
* console.log(result1);
|
|
555
|
-
*
|
|
556
|
-
* await cache.add("a", 2)
|
|
557
|
-
*
|
|
558
|
-
* const result2 = await cache.getAndRemove("a");
|
|
559
|
-
* // Will print 2
|
|
560
|
-
* console.log(result2);
|
|
561
|
-
*
|
|
562
|
-
* const result3 = await cache.get("a");
|
|
563
|
-
* // Will print null
|
|
564
|
-
* console.log(result3);
|
|
565
|
-
* ```
|
|
566
|
-
*/
|
|
567
|
-
getAndRemove(key: string): LazyPromise<TType | null>;
|
|
568
|
-
/**
|
|
569
|
-
* @example
|
|
570
|
-
* ```ts
|
|
571
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
572
|
-
* import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
|
|
573
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
574
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
575
|
-
*
|
|
576
|
-
* const cache: IGroupableCache = new Cache({
|
|
577
|
-
* adapter: new MemoryCacheAdapter({
|
|
578
|
-
* rootGroup: "@global"
|
|
579
|
-
* }),
|
|
580
|
-
* });
|
|
581
|
-
*
|
|
582
|
-
* const result = await cache.getOrAdd("a", -1);
|
|
583
|
-
* // -1
|
|
584
|
-
* console.log(result);
|
|
585
|
-
* ```
|
|
586
|
-
*
|
|
587
|
-
* You can pass function as default value.
|
|
588
|
-
* @example
|
|
589
|
-
* ```ts
|
|
590
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
591
|
-
* import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
|
|
592
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
593
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
594
|
-
*
|
|
595
|
-
* const cache: IGroupableCache = new Cache({
|
|
596
|
-
* adapter: new MemoryCacheAdapter({
|
|
597
|
-
* rootGroup: "@global"
|
|
598
|
-
* }),
|
|
599
|
-
* });
|
|
600
|
-
*
|
|
601
|
-
* const result = await cache.getOrAdd("a", () => -1);
|
|
602
|
-
* // -1
|
|
603
|
-
* console.log(result);
|
|
604
|
-
* ```
|
|
605
|
-
*
|
|
606
|
-
* You can pass async function as default value.
|
|
607
|
-
* @example
|
|
608
|
-
* ```ts
|
|
609
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
610
|
-
* import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
|
|
611
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
612
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
613
|
-
*
|
|
614
|
-
* const cache: IGroupableCache = new Cache({
|
|
615
|
-
* adapter: new MemoryCacheAdapter({
|
|
616
|
-
* rootGroup: "@global"
|
|
617
|
-
* }),
|
|
618
|
-
* });
|
|
619
|
-
*
|
|
620
|
-
* const result = await cache.getOrAdd("a", async () => -1);
|
|
621
|
-
* // -1
|
|
622
|
-
* console.log(result);
|
|
623
|
-
* ```
|
|
624
|
-
*
|
|
625
|
-
* You can pass <i>{@link LazyPromise}</i> as default value.
|
|
626
|
-
* @example
|
|
627
|
-
* ```ts
|
|
628
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
629
|
-
* import type { IGroupableEventBus } from "@daiso-tech/core/event-bus/contracts";
|
|
630
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
631
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
632
|
-
*
|
|
633
|
-
* const cache: IGroupableCache = new Cache({
|
|
634
|
-
* adapter: new MemoryCacheAdapter({
|
|
635
|
-
* rootGroup: "@global"
|
|
636
|
-
* }),
|
|
637
|
-
* });
|
|
638
|
-
*
|
|
639
|
-
* const result = await cache.getOrAdd("a", new LazyPromise(async () => -1));
|
|
640
|
-
* // -1
|
|
641
|
-
* console.log(result);
|
|
642
|
-
* ```
|
|
643
|
-
*/
|
|
644
|
-
getOrAdd(key: string, valueToAdd: AsyncLazyable<GetOrAddValue<TType>>,
|
|
645
|
-
/**
|
|
646
|
-
* @default {null}
|
|
647
|
-
*/
|
|
648
|
-
ttl?: TimeSpan): LazyPromise<TType>;
|
|
649
|
-
decrement(key: string, value?: Extract<TType, number>): LazyPromise<boolean>;
|
|
205
|
+
getGroup(): string | null;
|
|
206
|
+
withGroup(group: OneOrMore<string>): ICache<TType>;
|
|
650
207
|
}
|