lakutata 2.0.34 → 2.0.35
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/com/cacher.cjs +211 -0
- package/com/cacher.d.ts +514 -0
- package/com/cacher.mjs +185 -0
- package/com/database.cjs +6 -2
- package/com/database.mjs +6 -2
- package/com/docker.cjs +23 -17
- package/com/docker.mjs +19 -13
- package/com/entrypoint.cjs +1 -1
- package/com/entrypoint.mjs +1 -1
- package/com/logger.cjs +6 -2
- package/com/logger.mjs +6 -2
- package/decorator/ctrl.cjs +1 -1
- package/decorator/ctrl.mjs +1 -1
- package/decorator/orm.cjs +22 -18
- package/decorator/orm.mjs +6 -2
- package/helper.cjs +1 -1
- package/helper.mjs +1 -1
- package/lakutata.cjs +7 -3
- package/lakutata.mjs +7 -3
- package/orm.cjs +19 -15
- package/orm.mjs +15 -11
- package/package.json +6 -1
- package/provider/database.cjs +6 -2
- package/provider/database.mjs +6 -2
- package/src/components/Database.cjs +6 -2
- package/src/components/Database.mjs +6 -2
- package/src/components/Logger.cjs +6 -2
- package/src/components/Logger.mjs +6 -2
- package/src/components/cacher/Cacher.cjs +193 -0
- package/src/components/cacher/Cacher.mjs +183 -0
- package/src/components/cacher/options/CacherOptions.cjs +93 -0
- package/src/components/cacher/options/CacherOptions.mjs +87 -0
- package/src/components/cacher/options/FileCacheOptions.cjs +77 -0
- package/src/components/cacher/options/FileCacheOptions.mjs +71 -0
- package/src/components/cacher/options/MemcacheCacheOptions.cjs +79 -0
- package/src/components/cacher/options/MemcacheCacheOptions.mjs +73 -0
- package/src/components/cacher/options/MongoCacheOptions.cjs +83 -0
- package/src/components/cacher/options/MongoCacheOptions.mjs +77 -0
- package/src/components/cacher/options/MysqlCacheOptions.cjs +83 -0
- package/src/components/cacher/options/MysqlCacheOptions.mjs +77 -0
- package/src/components/cacher/options/PostgresCacheOptions.cjs +87 -0
- package/src/components/cacher/options/PostgresCacheOptions.mjs +81 -0
- package/src/components/cacher/options/RedisCacheOptions.cjs +99 -0
- package/src/components/cacher/options/RedisCacheOptions.mjs +93 -0
- package/src/components/cacher/options/SqliteCacheOptions.cjs +77 -0
- package/src/components/cacher/options/SqliteCacheOptions.mjs +71 -0
- package/src/components/cacher/types/CacheStoreOptions.cjs +1 -0
- package/src/components/cacher/types/CacheStoreOptions.mjs +1 -0
- package/src/components/docker/ConnectionOptionsBuilder.cjs +19 -13
- package/src/components/docker/ConnectionOptionsBuilder.mjs +19 -13
- package/src/components/docker/Docker.cjs +19 -13
- package/src/components/docker/Docker.mjs +19 -13
- package/src/components/docker/lib/DockerContainer.cjs +26 -20
- package/src/components/docker/lib/DockerContainer.mjs +20 -14
- package/src/components/docker/lib/DockerContainerTTY.cjs +15 -9
- package/src/components/docker/lib/DockerContainerTTY.mjs +15 -9
- package/src/components/entrypoint/Entrypoint.cjs +1 -1
- package/src/components/entrypoint/Entrypoint.mjs +1 -1
- package/src/decorators/ctrl/CLIAction.cjs +1 -1
- package/src/decorators/ctrl/CLIAction.mjs +1 -1
- package/src/decorators/ctrl/HTTPAction.cjs +1 -1
- package/src/decorators/ctrl/HTTPAction.mjs +1 -1
- package/src/decorators/ctrl/ServiceAction.cjs +1 -1
- package/src/decorators/ctrl/ServiceAction.mjs +1 -1
- package/src/decorators/ctrl/http/DELETE.cjs +1 -1
- package/src/decorators/ctrl/http/DELETE.mjs +1 -1
- package/src/decorators/ctrl/http/GET.cjs +1 -1
- package/src/decorators/ctrl/http/GET.mjs +1 -1
- package/src/decorators/ctrl/http/HEAD.cjs +1 -1
- package/src/decorators/ctrl/http/HEAD.mjs +1 -1
- package/src/decorators/ctrl/http/OPTIONS.cjs +1 -1
- package/src/decorators/ctrl/http/OPTIONS.mjs +1 -1
- package/src/decorators/ctrl/http/PATCH.cjs +1 -1
- package/src/decorators/ctrl/http/PATCH.mjs +1 -1
- package/src/decorators/ctrl/http/POST.cjs +1 -1
- package/src/decorators/ctrl/http/POST.mjs +1 -1
- package/src/decorators/ctrl/http/PUT.cjs +1 -1
- package/src/decorators/ctrl/http/PUT.mjs +1 -1
- package/src/decorators/orm/AfterInsert.cjs +6 -2
- package/src/decorators/orm/AfterInsert.mjs +13 -9
- package/src/decorators/orm/AfterLoad.cjs +6 -2
- package/src/decorators/orm/AfterLoad.mjs +16 -12
- package/src/decorators/orm/AfterRecover.cjs +6 -2
- package/src/decorators/orm/AfterRecover.mjs +10 -6
- package/src/decorators/orm/AfterRemove.cjs +6 -2
- package/src/decorators/orm/AfterRemove.mjs +10 -6
- package/src/decorators/orm/AfterSoftRemove.cjs +6 -2
- package/src/decorators/orm/AfterSoftRemove.mjs +10 -6
- package/src/decorators/orm/AfterUpdate.cjs +6 -2
- package/src/decorators/orm/AfterUpdate.mjs +14 -10
- package/src/decorators/orm/BeforeInsert.cjs +6 -2
- package/src/decorators/orm/BeforeInsert.mjs +10 -6
- package/src/decorators/orm/BeforeRecover.cjs +13 -9
- package/src/decorators/orm/BeforeRecover.mjs +6 -2
- package/src/decorators/orm/BeforeRemove.cjs +13 -9
- package/src/decorators/orm/BeforeRemove.mjs +6 -2
- package/src/decorators/orm/BeforeSoftRemove.cjs +10 -6
- package/src/decorators/orm/BeforeSoftRemove.mjs +6 -2
- package/src/decorators/orm/BeforeUpdate.cjs +6 -2
- package/src/decorators/orm/BeforeUpdate.mjs +11 -7
- package/src/decorators/orm/Check.cjs +6 -2
- package/src/decorators/orm/Check.mjs +6 -2
- package/src/decorators/orm/ChildEntity.cjs +11 -7
- package/src/decorators/orm/ChildEntity.mjs +6 -2
- package/src/decorators/orm/Column.cjs +23 -19
- package/src/decorators/orm/Column.mjs +6 -2
- package/src/decorators/orm/CreateDateColumn.cjs +8 -4
- package/src/decorators/orm/CreateDateColumn.mjs +6 -2
- package/src/decorators/orm/DeleteDateColumn.cjs +6 -2
- package/src/decorators/orm/DeleteDateColumn.mjs +6 -2
- package/src/decorators/orm/Entity.cjs +6 -2
- package/src/decorators/orm/Entity.mjs +12 -8
- package/src/decorators/orm/EventSubscriber.cjs +6 -2
- package/src/decorators/orm/EventSubscriber.mjs +6 -2
- package/src/decorators/orm/Exclusion.cjs +6 -2
- package/src/decorators/orm/Exclusion.mjs +12 -8
- package/src/decorators/orm/Generated.cjs +10 -6
- package/src/decorators/orm/Generated.mjs +12 -8
- package/src/decorators/orm/Index.cjs +14 -10
- package/src/decorators/orm/Index.mjs +24 -20
- package/src/decorators/orm/JoinColumn.cjs +6 -2
- package/src/decorators/orm/JoinColumn.mjs +6 -2
- package/src/decorators/orm/JoinTable.cjs +6 -2
- package/src/decorators/orm/JoinTable.mjs +8 -4
- package/src/decorators/orm/ManyToMany.cjs +13 -9
- package/src/decorators/orm/ManyToMany.mjs +17 -13
- package/src/decorators/orm/ManyToOne.cjs +6 -2
- package/src/decorators/orm/ManyToOne.mjs +6 -2
- package/src/decorators/orm/ObjectIdColumn.cjs +6 -2
- package/src/decorators/orm/ObjectIdColumn.mjs +12 -8
- package/src/decorators/orm/OneToMany.cjs +14 -10
- package/src/decorators/orm/OneToMany.mjs +6 -2
- package/src/decorators/orm/OneToOne.cjs +15 -11
- package/src/decorators/orm/OneToOne.mjs +13 -9
- package/src/decorators/orm/PrimaryColumn.cjs +6 -2
- package/src/decorators/orm/PrimaryColumn.mjs +26 -22
- package/src/decorators/orm/PrimaryGeneratedColumn.cjs +6 -2
- package/src/decorators/orm/PrimaryGeneratedColumn.mjs +8 -4
- package/src/decorators/orm/RelationId.cjs +11 -7
- package/src/decorators/orm/RelationId.mjs +12 -8
- package/src/decorators/orm/TableInheritance.cjs +6 -2
- package/src/decorators/orm/TableInheritance.mjs +10 -6
- package/src/decorators/orm/Tree.cjs +6 -2
- package/src/decorators/orm/Tree.mjs +6 -2
- package/src/decorators/orm/TreeChildren.cjs +6 -2
- package/src/decorators/orm/TreeChildren.mjs +17 -13
- package/src/decorators/orm/TreeLevelColumn.cjs +6 -2
- package/src/decorators/orm/TreeLevelColumn.mjs +6 -2
- package/src/decorators/orm/TreeParent.cjs +12 -8
- package/src/decorators/orm/TreeParent.mjs +6 -2
- package/src/decorators/orm/Unique.cjs +6 -2
- package/src/decorators/orm/Unique.mjs +6 -2
- package/src/decorators/orm/UpdateDateColumn.cjs +8 -4
- package/src/decorators/orm/UpdateDateColumn.mjs +6 -2
- package/src/decorators/orm/VersionColumn.cjs +6 -2
- package/src/decorators/orm/VersionColumn.mjs +6 -2
- package/src/decorators/orm/ViewColumn.cjs +6 -2
- package/src/decorators/orm/ViewColumn.mjs +6 -2
- package/src/decorators/orm/ViewEntity.cjs +8 -4
- package/src/decorators/orm/ViewEntity.mjs +6 -2
- package/src/decorators/orm/VirtualColumn.cjs +6 -2
- package/src/decorators/orm/VirtualColumn.mjs +10 -6
- package/src/lib/base/internal/ControllerEntrypoint.cjs +1 -1
- package/src/lib/base/internal/ControllerEntrypoint.mjs +1 -1
- package/src/lib/core/Application.cjs +11 -7
- package/src/lib/core/Application.mjs +7 -3
- package/src/lib/core/Module.cjs +1 -1
- package/src/lib/core/Module.mjs +1 -1
- package/src/lib/helpers/NonceStr.cjs +1 -1
- package/src/lib/helpers/NonceStr.mjs +1 -1
- package/src/lib/helpers/ObjectHash.cjs +1 -1
- package/src/lib/helpers/ObjectHash.mjs +1 -1
- package/src/lib/helpers/RandomString.cjs +1 -1
- package/src/lib/helpers/RandomString.mjs +1 -1
- package/src/providers/Database.cjs +6 -2
- package/src/providers/Database.mjs +6 -2
- package/vendor/Package.112.cjs +5498 -5500
- package/vendor/Package.112.mjs +5504 -5506
- package/vendor/Package.12.cjs +4 -80
- package/vendor/Package.12.mjs +4 -74
- package/vendor/Package.122.cjs +87 -0
- package/vendor/Package.122.mjs +79 -0
- package/vendor/Package.13.cjs +1 -1
- package/vendor/Package.13.mjs +1 -1
- package/vendor/Package.14.cjs +1 -14055
- package/vendor/Package.14.mjs +1 -14029
- package/vendor/Package.15.cjs +12449 -46635
- package/vendor/Package.15.mjs +12435 -46611
- package/vendor/Package.16.cjs +3 -0
- package/vendor/Package.16.mjs +1 -0
- package/vendor/Package.17.cjs +48245 -0
- package/vendor/Package.17.mjs +48202 -0
- package/vendor/Package.18.cjs +3 -0
- package/vendor/Package.18.mjs +1 -0
- package/vendor/Package.19.cjs +4466 -0
- package/vendor/Package.19.mjs +4442 -0
- package/vendor/Package.610.cjs +196 -0
- package/vendor/Package.610.mjs +180 -0
- package/vendor/Package.62.cjs +1 -1
- package/vendor/Package.62.mjs +1 -1
- package/vendor/Package.65.cjs +860 -0
- package/vendor/Package.65.mjs +832 -0
- package/vendor/Package.66.cjs +321 -0
- package/vendor/Package.66.mjs +305 -0
- package/vendor/Package.67.cjs +341 -0
- package/vendor/Package.67.mjs +327 -0
- package/vendor/Package.68.cjs +333 -0
- package/vendor/Package.68.mjs +315 -0
- package/vendor/Package.69.cjs +353 -0
- package/vendor/Package.69.mjs +335 -0
|
@@ -0,0 +1,832 @@
|
|
|
1
|
+
import { createClient as t, createCluster as e } from "@redis/client";
|
|
2
|
+
|
|
3
|
+
export { createClient, createCluster } from "@redis/client";
|
|
4
|
+
|
|
5
|
+
import { K as s } from "./Package.19.mjs";
|
|
6
|
+
|
|
7
|
+
import r from "cluster-key-slot";
|
|
8
|
+
|
|
9
|
+
import "./Package.1.mjs";
|
|
10
|
+
|
|
11
|
+
import "events";
|
|
12
|
+
|
|
13
|
+
import "buffer";
|
|
14
|
+
|
|
15
|
+
import "./Package.5.mjs";
|
|
16
|
+
|
|
17
|
+
import "./Package.12.mjs";
|
|
18
|
+
|
|
19
|
+
import "./Package.8.mjs";
|
|
20
|
+
|
|
21
|
+
import "os";
|
|
22
|
+
|
|
23
|
+
import "path";
|
|
24
|
+
|
|
25
|
+
import "stream";
|
|
26
|
+
|
|
27
|
+
import "fs";
|
|
28
|
+
|
|
29
|
+
import "./Package.18.mjs";
|
|
30
|
+
|
|
31
|
+
import "constants";
|
|
32
|
+
|
|
33
|
+
import "./Package.10.mjs";
|
|
34
|
+
|
|
35
|
+
import "url";
|
|
36
|
+
|
|
37
|
+
import "util";
|
|
38
|
+
|
|
39
|
+
import "./Package.16.mjs";
|
|
40
|
+
|
|
41
|
+
import "assert";
|
|
42
|
+
|
|
43
|
+
import "./Package.13.mjs";
|
|
44
|
+
|
|
45
|
+
import "../src/components/cacher/options/CacherOptions.mjs";
|
|
46
|
+
|
|
47
|
+
import "./Package.2.mjs";
|
|
48
|
+
|
|
49
|
+
import "../src/lib/base/internal/DataValidator.mjs";
|
|
50
|
+
|
|
51
|
+
import "./Package.4.mjs";
|
|
52
|
+
|
|
53
|
+
import "node:util/types";
|
|
54
|
+
|
|
55
|
+
import "../src/lib/validation/VLD.mjs";
|
|
56
|
+
|
|
57
|
+
import "../src/exceptions/dto/InvalidValueException.mjs";
|
|
58
|
+
|
|
59
|
+
import "../src/lib/base/abstracts/Exception.mjs";
|
|
60
|
+
|
|
61
|
+
import "../src/lib/base/internal/BasicInfo.mjs";
|
|
62
|
+
|
|
63
|
+
import "../src/lib/helpers/As.mjs";
|
|
64
|
+
|
|
65
|
+
import "./Package.6.mjs";
|
|
66
|
+
|
|
67
|
+
import "./Package.7.mjs";
|
|
68
|
+
|
|
69
|
+
import "../src/lib/base/internal/ThrowWarning.mjs";
|
|
70
|
+
|
|
71
|
+
import "../src/lib/helpers/Templating.mjs";
|
|
72
|
+
|
|
73
|
+
import "../src/lib/base/internal/CamelCase.mjs";
|
|
74
|
+
|
|
75
|
+
import "../src/lib/helpers/NoCase.mjs";
|
|
76
|
+
|
|
77
|
+
import "./Package.9.mjs";
|
|
78
|
+
|
|
79
|
+
import "../src/lib/helpers/IsHtml.mjs";
|
|
80
|
+
|
|
81
|
+
import "../src/lib/helpers/IsXML.mjs";
|
|
82
|
+
|
|
83
|
+
import "../src/constants/DTOMetadataKey.mjs";
|
|
84
|
+
|
|
85
|
+
import "../src/lib/helpers/ObjectConstructor.mjs";
|
|
86
|
+
|
|
87
|
+
import "../src/lib/helpers/ObjectParentConstructors.mjs";
|
|
88
|
+
|
|
89
|
+
import "../src/lib/helpers/ObjectParentConstructor.mjs";
|
|
90
|
+
|
|
91
|
+
import "../src/lib/helpers/ObjectPrototype.mjs";
|
|
92
|
+
|
|
93
|
+
import "../src/decorators/dto/Expect.mjs";
|
|
94
|
+
|
|
95
|
+
import "../src/components/cacher/options/FileCacheOptions.mjs";
|
|
96
|
+
|
|
97
|
+
import "../src/components/cacher/options/MemcacheCacheOptions.mjs";
|
|
98
|
+
|
|
99
|
+
import "../src/components/cacher/options/MongoCacheOptions.mjs";
|
|
100
|
+
|
|
101
|
+
import "../src/components/cacher/options/PostgresCacheOptions.mjs";
|
|
102
|
+
|
|
103
|
+
import "../src/components/cacher/options/MysqlCacheOptions.mjs";
|
|
104
|
+
|
|
105
|
+
import "../src/components/cacher/options/SqliteCacheOptions.mjs";
|
|
106
|
+
|
|
107
|
+
import "../src/components/cacher/options/RedisCacheOptions.mjs";
|
|
108
|
+
|
|
109
|
+
import "../src/lib/core/Component.mjs";
|
|
110
|
+
|
|
111
|
+
import "./Package.3.mjs";
|
|
112
|
+
|
|
113
|
+
import "../src/lib/base/async-constructor/AsyncConstructor.mjs";
|
|
114
|
+
|
|
115
|
+
import "../src/lib/base/async-constructor/Append.mjs";
|
|
116
|
+
|
|
117
|
+
import "../src/lib/helpers/IsPromiseLike.mjs";
|
|
118
|
+
|
|
119
|
+
import "../src/lib/helpers/IsPromise.mjs";
|
|
120
|
+
|
|
121
|
+
import "util/types";
|
|
122
|
+
|
|
123
|
+
import "../src/decorators/di/Lifetime.mjs";
|
|
124
|
+
|
|
125
|
+
import "../src/lib/base/internal/ObjectLifetime.mjs";
|
|
126
|
+
|
|
127
|
+
import "../src/constants/DIMetadataKey.mjs";
|
|
128
|
+
|
|
129
|
+
import "../src/exceptions/di/LifetimeLockedException.mjs";
|
|
130
|
+
|
|
131
|
+
import "../src/exceptions/MethodNotFoundException.mjs";
|
|
132
|
+
|
|
133
|
+
import "../src/lib/ioc/DependencyInjectionContainer.mjs";
|
|
134
|
+
|
|
135
|
+
import "../src/lib/ioc/Errors.mjs";
|
|
136
|
+
|
|
137
|
+
import "../src/exceptions/di/DependencyInjectionException.mjs";
|
|
138
|
+
|
|
139
|
+
import "../src/lib/base/internal/ConstructorSymbol.mjs";
|
|
140
|
+
|
|
141
|
+
import "node:crypto";
|
|
142
|
+
|
|
143
|
+
import "../src/lib/ioc/InjectionMode.mjs";
|
|
144
|
+
|
|
145
|
+
import "../src/lib/ioc/Lifetime.mjs";
|
|
146
|
+
|
|
147
|
+
import "../src/lib/ioc/ListModules.mjs";
|
|
148
|
+
|
|
149
|
+
import "../src/lib/ioc/Utils.mjs";
|
|
150
|
+
|
|
151
|
+
import "../src/lib/ioc/FunctionTokenizer.mjs";
|
|
152
|
+
|
|
153
|
+
import "../src/lib/ioc/LoadModules.mjs";
|
|
154
|
+
|
|
155
|
+
import "../src/lib/ioc/Resolvers.mjs";
|
|
156
|
+
|
|
157
|
+
import "../src/lib/ioc/ParamParser.mjs";
|
|
158
|
+
|
|
159
|
+
import "../src/lib/base/internal/ObjectWeakRefs.mjs";
|
|
160
|
+
|
|
161
|
+
import "../src/lib/base/internal/ConfigurableRecordsInjection.mjs";
|
|
162
|
+
|
|
163
|
+
import "../src/lib/base/internal/ObjectConfiguration.mjs";
|
|
164
|
+
|
|
165
|
+
import "../src/lib/base/internal/ObjectInjection.mjs";
|
|
166
|
+
|
|
167
|
+
import "../src/lib/base/internal/ObjectContainer.mjs";
|
|
168
|
+
|
|
169
|
+
import "../src/lib/helpers/DevNull.mjs";
|
|
170
|
+
|
|
171
|
+
import "../src/decorators/dto/IndexSignature.mjs";
|
|
172
|
+
|
|
173
|
+
import "../src/decorators/dto/Accept.mjs";
|
|
174
|
+
|
|
175
|
+
import "../src/lib/base/internal/MethodValidation.mjs";
|
|
176
|
+
|
|
177
|
+
import "../src/exceptions/dto/InvalidMethodAcceptException.mjs";
|
|
178
|
+
|
|
179
|
+
import "../src/exceptions/dto/InvalidMethodReturnException.mjs";
|
|
180
|
+
|
|
181
|
+
import "../src/lib/helpers/IsEmptyObject.mjs";
|
|
182
|
+
|
|
183
|
+
import "../src/lib/base/EventEmitter.mjs";
|
|
184
|
+
|
|
185
|
+
import "../src/lib/core/Provider.mjs";
|
|
186
|
+
|
|
187
|
+
import "../src/decorators/di/Configurable.mjs";
|
|
188
|
+
|
|
189
|
+
import "../src/lib/helpers/URLBuilder.mjs";
|
|
190
|
+
|
|
191
|
+
var i = class {
|
|
192
|
+
_eventListeners;
|
|
193
|
+
_maxListeners;
|
|
194
|
+
_logger;
|
|
195
|
+
constructor(t) {
|
|
196
|
+
this._eventListeners = new Map, this._maxListeners = 100, this._logger = t?.logger;
|
|
197
|
+
}
|
|
198
|
+
once(t, e) {
|
|
199
|
+
let s = (...r) => {
|
|
200
|
+
this.off(t, s), e(...r);
|
|
201
|
+
};
|
|
202
|
+
return this.on(t, s), this;
|
|
203
|
+
}
|
|
204
|
+
listenerCount(t) {
|
|
205
|
+
if (!t) return this.getAllListeners().length;
|
|
206
|
+
let e = this._eventListeners.get(t);
|
|
207
|
+
return e ? e.length : 0;
|
|
208
|
+
}
|
|
209
|
+
eventNames() {
|
|
210
|
+
return [ ...this._eventListeners.keys() ];
|
|
211
|
+
}
|
|
212
|
+
rawListeners(t) {
|
|
213
|
+
return t ? this._eventListeners.get(t) ?? [] : this.getAllListeners();
|
|
214
|
+
}
|
|
215
|
+
prependListener(t, e) {
|
|
216
|
+
let s = this._eventListeners.get(t) ?? [];
|
|
217
|
+
return s.unshift(e), this._eventListeners.set(t, s), this;
|
|
218
|
+
}
|
|
219
|
+
prependOnceListener(t, e) {
|
|
220
|
+
let s = (...r) => {
|
|
221
|
+
this.off(t, s), e(...r);
|
|
222
|
+
};
|
|
223
|
+
return this.prependListener(t, s), this;
|
|
224
|
+
}
|
|
225
|
+
maxListeners() {
|
|
226
|
+
return this._maxListeners;
|
|
227
|
+
}
|
|
228
|
+
addListener(t, e) {
|
|
229
|
+
return this.on(t, e), this;
|
|
230
|
+
}
|
|
231
|
+
on(t, e) {
|
|
232
|
+
this._eventListeners.has(t) || this._eventListeners.set(t, []);
|
|
233
|
+
let s = this._eventListeners.get(t);
|
|
234
|
+
return s && (s.length >= this._maxListeners && console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${s.length + 1} ${t} listeners added. Use setMaxListeners() to increase limit.`),
|
|
235
|
+
s.push(e)), this;
|
|
236
|
+
}
|
|
237
|
+
removeListener(t, e) {
|
|
238
|
+
return this.off(t, e), this;
|
|
239
|
+
}
|
|
240
|
+
off(t, e) {
|
|
241
|
+
let s = this._eventListeners.get(t) ?? [], r = s.indexOf(e);
|
|
242
|
+
return r !== -1 && s.splice(r, 1), s.length === 0 && this._eventListeners.delete(t),
|
|
243
|
+
this;
|
|
244
|
+
}
|
|
245
|
+
emit(t, ...e) {
|
|
246
|
+
let s = !1, r = this._eventListeners.get(t);
|
|
247
|
+
if (r && r.length > 0) for (let t of r) t(...e), s = !0;
|
|
248
|
+
return s;
|
|
249
|
+
}
|
|
250
|
+
listeners(t) {
|
|
251
|
+
return this._eventListeners.get(t) ?? [];
|
|
252
|
+
}
|
|
253
|
+
removeAllListeners(t) {
|
|
254
|
+
return t ? this._eventListeners.delete(t) : this._eventListeners.clear(), this;
|
|
255
|
+
}
|
|
256
|
+
setMaxListeners(t) {
|
|
257
|
+
this._maxListeners = t;
|
|
258
|
+
for (let e of this._eventListeners.values()) e.length > t && e.splice(t);
|
|
259
|
+
}
|
|
260
|
+
getAllListeners() {
|
|
261
|
+
let t = new Array;
|
|
262
|
+
for (let e of this._eventListeners.values()) t = [ ...t, ...e ];
|
|
263
|
+
return t;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
var o = class extends i {
|
|
268
|
+
_hooks;
|
|
269
|
+
_throwHookErrors=!1;
|
|
270
|
+
constructor(t) {
|
|
271
|
+
super({
|
|
272
|
+
logger: t?.logger
|
|
273
|
+
}), this._hooks = new Map, t?.throwHookErrors !== void 0 && (this._throwHookErrors = t.throwHookErrors);
|
|
274
|
+
}
|
|
275
|
+
get hooks() {
|
|
276
|
+
return this._hooks;
|
|
277
|
+
}
|
|
278
|
+
get throwHookErrors() {
|
|
279
|
+
return this._throwHookErrors;
|
|
280
|
+
}
|
|
281
|
+
set throwHookErrors(t) {
|
|
282
|
+
this._throwHookErrors = t;
|
|
283
|
+
}
|
|
284
|
+
get logger() {
|
|
285
|
+
return this._logger;
|
|
286
|
+
}
|
|
287
|
+
set logger(t) {
|
|
288
|
+
this._logger = t;
|
|
289
|
+
}
|
|
290
|
+
onHook(t, e) {
|
|
291
|
+
let s = this._hooks.get(t);
|
|
292
|
+
s ? s.push(e) : this._hooks.set(t, [ e ]);
|
|
293
|
+
}
|
|
294
|
+
addHook(t, e) {
|
|
295
|
+
this.onHook(t, e);
|
|
296
|
+
}
|
|
297
|
+
onHooks(t) {
|
|
298
|
+
for (let e of t) this.onHook(e.event, e.handler);
|
|
299
|
+
}
|
|
300
|
+
prependHook(t, e) {
|
|
301
|
+
let s = this._hooks.get(t);
|
|
302
|
+
s ? s.unshift(e) : this._hooks.set(t, [ e ]);
|
|
303
|
+
}
|
|
304
|
+
prependOnceHook(t, e) {
|
|
305
|
+
let s = async (...r) => (this.removeHook(t, s), e(...r));
|
|
306
|
+
this.prependHook(t, s);
|
|
307
|
+
}
|
|
308
|
+
onceHook(t, e) {
|
|
309
|
+
let s = async (...r) => (this.removeHook(t, s), e(...r));
|
|
310
|
+
this.onHook(t, s);
|
|
311
|
+
}
|
|
312
|
+
removeHook(t, e) {
|
|
313
|
+
let s = this._hooks.get(t);
|
|
314
|
+
if (s) {
|
|
315
|
+
let t = s.indexOf(e);
|
|
316
|
+
t !== -1 && s.splice(t, 1);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
removeHooks(t) {
|
|
320
|
+
for (let e of t) this.removeHook(e.event, e.handler);
|
|
321
|
+
}
|
|
322
|
+
async hook(t, ...e) {
|
|
323
|
+
let s = this._hooks.get(t);
|
|
324
|
+
if (s) for (let r of s) try {
|
|
325
|
+
await r(...e);
|
|
326
|
+
} catch (e) {
|
|
327
|
+
let s = `${t}: ${e.message}`;
|
|
328
|
+
if (this.emit("error", new Error(s)), this._logger && this._logger.error(s), this._throwHookErrors) throw new Error(s);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
async callHook(t, ...e) {
|
|
332
|
+
await this.hook(t, ...e);
|
|
333
|
+
}
|
|
334
|
+
getHooks(t) {
|
|
335
|
+
return this._hooks.get(t);
|
|
336
|
+
}
|
|
337
|
+
clearHooks() {
|
|
338
|
+
this._hooks.clear();
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
var n = (t => {
|
|
343
|
+
t["RedisClientNotConnectedThrown"] = "Redis client is not connected or has failed to connect. This is thrown because throwOnConnectError is set to true.";
|
|
344
|
+
return t;
|
|
345
|
+
})(n || {});
|
|
346
|
+
|
|
347
|
+
var c = t => {
|
|
348
|
+
const e = Math.min(2 ** t * 100, 2e3);
|
|
349
|
+
const s = (Math.random() - .5) * 100;
|
|
350
|
+
return e + s;
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
var a = class extends o {
|
|
354
|
+
_client=t();
|
|
355
|
+
_namespace;
|
|
356
|
+
_keyPrefixSeparator="::";
|
|
357
|
+
_clearBatchSize=1e3;
|
|
358
|
+
_useUnlink=true;
|
|
359
|
+
_noNamespaceAffectsAll=false;
|
|
360
|
+
_throwOnConnectError=true;
|
|
361
|
+
_throwErrors=false;
|
|
362
|
+
_connectionTimeout;
|
|
363
|
+
constructor(s, r) {
|
|
364
|
+
super();
|
|
365
|
+
const i = {
|
|
366
|
+
reconnectStrategy: c
|
|
367
|
+
};
|
|
368
|
+
if (s) {
|
|
369
|
+
if (typeof s === "string") {
|
|
370
|
+
this._client = t({
|
|
371
|
+
url: s,
|
|
372
|
+
socket: i
|
|
373
|
+
});
|
|
374
|
+
} else if (s.connect !== void 0) {
|
|
375
|
+
this._client = this.isClientCluster(s) ? s : s;
|
|
376
|
+
} else if (s instanceof Object) {
|
|
377
|
+
this._client = s.rootNodes === void 0 ? t(s) : e(s);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
this.setOptions(r);
|
|
381
|
+
this.initClient();
|
|
382
|
+
}
|
|
383
|
+
get client() {
|
|
384
|
+
return this._client;
|
|
385
|
+
}
|
|
386
|
+
set client(t) {
|
|
387
|
+
this._client = t;
|
|
388
|
+
this.initClient();
|
|
389
|
+
}
|
|
390
|
+
get opts() {
|
|
391
|
+
let t = "redis://localhost:6379";
|
|
392
|
+
if (this._client.options) {
|
|
393
|
+
const e = this._client.options?.url;
|
|
394
|
+
if (e) {
|
|
395
|
+
t = e;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
const e = {
|
|
399
|
+
namespace: this._namespace,
|
|
400
|
+
keyPrefixSeparator: this._keyPrefixSeparator,
|
|
401
|
+
clearBatchSize: this._clearBatchSize,
|
|
402
|
+
noNamespaceAffectsAll: this._noNamespaceAffectsAll,
|
|
403
|
+
useUnlink: this._useUnlink,
|
|
404
|
+
throwOnConnectError: this._throwOnConnectError,
|
|
405
|
+
throwErrors: this._throwErrors,
|
|
406
|
+
connectionTimeout: this._connectionTimeout,
|
|
407
|
+
dialect: "redis",
|
|
408
|
+
url: t
|
|
409
|
+
};
|
|
410
|
+
return e;
|
|
411
|
+
}
|
|
412
|
+
set opts(t) {
|
|
413
|
+
this.setOptions(t);
|
|
414
|
+
}
|
|
415
|
+
get namespace() {
|
|
416
|
+
return this._namespace;
|
|
417
|
+
}
|
|
418
|
+
set namespace(t) {
|
|
419
|
+
this._namespace = t;
|
|
420
|
+
}
|
|
421
|
+
get keyPrefixSeparator() {
|
|
422
|
+
return this._keyPrefixSeparator;
|
|
423
|
+
}
|
|
424
|
+
set keyPrefixSeparator(t) {
|
|
425
|
+
this._keyPrefixSeparator = t;
|
|
426
|
+
}
|
|
427
|
+
get clearBatchSize() {
|
|
428
|
+
return this._clearBatchSize;
|
|
429
|
+
}
|
|
430
|
+
set clearBatchSize(t) {
|
|
431
|
+
if (t > 0) {
|
|
432
|
+
this._clearBatchSize = t;
|
|
433
|
+
} else {
|
|
434
|
+
this.emit("error", "clearBatchSize must be greater than 0");
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
get useUnlink() {
|
|
438
|
+
return this._useUnlink;
|
|
439
|
+
}
|
|
440
|
+
set useUnlink(t) {
|
|
441
|
+
this._useUnlink = t;
|
|
442
|
+
}
|
|
443
|
+
get noNamespaceAffectsAll() {
|
|
444
|
+
return this._noNamespaceAffectsAll;
|
|
445
|
+
}
|
|
446
|
+
set noNamespaceAffectsAll(t) {
|
|
447
|
+
this._noNamespaceAffectsAll = t;
|
|
448
|
+
}
|
|
449
|
+
get throwOnConnectError() {
|
|
450
|
+
return this._throwOnConnectError;
|
|
451
|
+
}
|
|
452
|
+
set throwOnConnectError(t) {
|
|
453
|
+
this._throwOnConnectError = t;
|
|
454
|
+
}
|
|
455
|
+
get throwErrors() {
|
|
456
|
+
return this._throwErrors;
|
|
457
|
+
}
|
|
458
|
+
set throwErrors(t) {
|
|
459
|
+
this._throwErrors = t;
|
|
460
|
+
}
|
|
461
|
+
get connectionTimeout() {
|
|
462
|
+
return this._connectionTimeout;
|
|
463
|
+
}
|
|
464
|
+
set connectionTimeout(t) {
|
|
465
|
+
this._connectionTimeout = t;
|
|
466
|
+
}
|
|
467
|
+
async getClient() {
|
|
468
|
+
if (this._client.isOpen) {
|
|
469
|
+
return this._client;
|
|
470
|
+
}
|
|
471
|
+
try {
|
|
472
|
+
if (this._connectionTimeout === void 0) {
|
|
473
|
+
await this._client.connect();
|
|
474
|
+
} else {
|
|
475
|
+
await Promise.race([ this._client.connect(), this.createTimeoutPromise(this._connectionTimeout) ]);
|
|
476
|
+
}
|
|
477
|
+
} catch (t) {
|
|
478
|
+
this.emit("error", t);
|
|
479
|
+
if (this._throwOnConnectError) {
|
|
480
|
+
throw new Error("Redis client is not connected or has failed to connect. This is thrown because throwOnConnectError is set to true.");
|
|
481
|
+
}
|
|
482
|
+
await this.disconnect(true);
|
|
483
|
+
}
|
|
484
|
+
this.initClient();
|
|
485
|
+
return this._client;
|
|
486
|
+
}
|
|
487
|
+
async set(t, e, s) {
|
|
488
|
+
const r = await this.getClient();
|
|
489
|
+
try {
|
|
490
|
+
t = this.createKeyPrefix(t, this._namespace);
|
|
491
|
+
if (s) {
|
|
492
|
+
await r.set(t, e, {
|
|
493
|
+
PX: s
|
|
494
|
+
});
|
|
495
|
+
} else {
|
|
496
|
+
await r.set(t, e);
|
|
497
|
+
}
|
|
498
|
+
} catch (t) {
|
|
499
|
+
this.emit("error", t);
|
|
500
|
+
if (this._throwErrors) {
|
|
501
|
+
throw t;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
async setMany(t) {
|
|
506
|
+
const e = await this.getClient();
|
|
507
|
+
try {
|
|
508
|
+
const s = e.multi();
|
|
509
|
+
for (const {key: e, value: r, ttl: i} of t) {
|
|
510
|
+
const t = this.createKeyPrefix(e, this._namespace);
|
|
511
|
+
if (i) {
|
|
512
|
+
s.set(t, r, {
|
|
513
|
+
PX: i
|
|
514
|
+
});
|
|
515
|
+
} else {
|
|
516
|
+
s.set(t, r);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
await s.exec();
|
|
520
|
+
} catch (t) {
|
|
521
|
+
this.emit("error", t);
|
|
522
|
+
if (this._throwErrors) {
|
|
523
|
+
throw t;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
async has(t) {
|
|
528
|
+
const e = await this.getClient();
|
|
529
|
+
try {
|
|
530
|
+
t = this.createKeyPrefix(t, this._namespace);
|
|
531
|
+
const s = await e.exists(t);
|
|
532
|
+
return s === 1;
|
|
533
|
+
} catch (t) {
|
|
534
|
+
this.emit("error", t);
|
|
535
|
+
if (this._throwErrors) {
|
|
536
|
+
throw t;
|
|
537
|
+
}
|
|
538
|
+
return false;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
async hasMany(t) {
|
|
542
|
+
const e = await this.getClient();
|
|
543
|
+
try {
|
|
544
|
+
const s = e.multi();
|
|
545
|
+
for (const e of t) {
|
|
546
|
+
const t = this.createKeyPrefix(e, this._namespace);
|
|
547
|
+
s.exists(t);
|
|
548
|
+
}
|
|
549
|
+
const r = await s.exec();
|
|
550
|
+
return r.map((t => t === 1));
|
|
551
|
+
} catch (e) {
|
|
552
|
+
this.emit("error", e);
|
|
553
|
+
if (this._throwErrors) {
|
|
554
|
+
throw e;
|
|
555
|
+
}
|
|
556
|
+
return Array.from({
|
|
557
|
+
length: t.length
|
|
558
|
+
}).fill(false);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
async get(t) {
|
|
562
|
+
const e = await this.getClient();
|
|
563
|
+
try {
|
|
564
|
+
t = this.createKeyPrefix(t, this._namespace);
|
|
565
|
+
const s = await e.get(t);
|
|
566
|
+
if (s === null) {
|
|
567
|
+
return void 0;
|
|
568
|
+
}
|
|
569
|
+
return s;
|
|
570
|
+
} catch (t) {
|
|
571
|
+
this.emit("error", t);
|
|
572
|
+
if (this._throwErrors) {
|
|
573
|
+
throw t;
|
|
574
|
+
}
|
|
575
|
+
return void 0;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
async getMany(t) {
|
|
579
|
+
if (t.length === 0) {
|
|
580
|
+
return [];
|
|
581
|
+
}
|
|
582
|
+
t = t.map((t => this.createKeyPrefix(t, this._namespace)));
|
|
583
|
+
try {
|
|
584
|
+
const e = await this.mget(t);
|
|
585
|
+
return e;
|
|
586
|
+
} catch (e) {
|
|
587
|
+
this.emit("error", e);
|
|
588
|
+
if (this._throwErrors) {
|
|
589
|
+
throw e;
|
|
590
|
+
}
|
|
591
|
+
return Array.from({
|
|
592
|
+
length: t.length
|
|
593
|
+
}).fill(void 0);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
async delete(t) {
|
|
597
|
+
const e = await this.getClient();
|
|
598
|
+
try {
|
|
599
|
+
t = this.createKeyPrefix(t, this._namespace);
|
|
600
|
+
let s = 0;
|
|
601
|
+
s = await (this._useUnlink ? e.unlink(t) : e.del(t));
|
|
602
|
+
return s > 0;
|
|
603
|
+
} catch (t) {
|
|
604
|
+
this.emit("error", t);
|
|
605
|
+
if (this._throwErrors) {
|
|
606
|
+
throw t;
|
|
607
|
+
}
|
|
608
|
+
return false;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
async deleteMany(t) {
|
|
612
|
+
let e = false;
|
|
613
|
+
const s = await this.getClient();
|
|
614
|
+
try {
|
|
615
|
+
const r = s.multi();
|
|
616
|
+
for (const e of t) {
|
|
617
|
+
const t = this.createKeyPrefix(e, this._namespace);
|
|
618
|
+
if (this._useUnlink) {
|
|
619
|
+
r.unlink(t);
|
|
620
|
+
} else {
|
|
621
|
+
r.del(t);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
const i = await r.exec();
|
|
625
|
+
for (const t of i) {
|
|
626
|
+
if (typeof t === "number" && t > 0) {
|
|
627
|
+
e = true;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
} catch (t) {
|
|
631
|
+
this.emit("error", t);
|
|
632
|
+
if (this._throwErrors) {
|
|
633
|
+
throw t;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
return e;
|
|
637
|
+
}
|
|
638
|
+
async disconnect(t) {
|
|
639
|
+
if (this._client.isOpen) {
|
|
640
|
+
await (t ? this._client.disconnect() : this._client.quit());
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
createKeyPrefix(t, e) {
|
|
644
|
+
if (e) {
|
|
645
|
+
return `${e}${this._keyPrefixSeparator}${t}`;
|
|
646
|
+
}
|
|
647
|
+
return t;
|
|
648
|
+
}
|
|
649
|
+
getKeyWithoutPrefix(t, e) {
|
|
650
|
+
if (e) {
|
|
651
|
+
return t.replace(`${e}${this._keyPrefixSeparator}`, "");
|
|
652
|
+
}
|
|
653
|
+
return t;
|
|
654
|
+
}
|
|
655
|
+
isCluster() {
|
|
656
|
+
return this.isClientCluster(this._client);
|
|
657
|
+
}
|
|
658
|
+
async getMasterNodes() {
|
|
659
|
+
if (this.isCluster()) {
|
|
660
|
+
const t = await this.getClient();
|
|
661
|
+
return Promise.all(t.masters.map((async e => t.nodeClient(e))));
|
|
662
|
+
}
|
|
663
|
+
return [ await this.getClient() ];
|
|
664
|
+
}
|
|
665
|
+
async* iterator(t) {
|
|
666
|
+
const e = await this.getMasterNodes();
|
|
667
|
+
for (const s of e) {
|
|
668
|
+
const e = t ? `${t}${this._keyPrefixSeparator}*` : "*";
|
|
669
|
+
let r = "0";
|
|
670
|
+
do {
|
|
671
|
+
const i = await s.scan(Number.parseInt(r, 10), {
|
|
672
|
+
MATCH: e,
|
|
673
|
+
TYPE: "string"
|
|
674
|
+
});
|
|
675
|
+
r = i.cursor.toString();
|
|
676
|
+
let {keys: o} = i;
|
|
677
|
+
if (!t && !this._noNamespaceAffectsAll) {
|
|
678
|
+
o = o.filter((t => !t.includes(this._keyPrefixSeparator)));
|
|
679
|
+
}
|
|
680
|
+
if (o.length > 0) {
|
|
681
|
+
const e = await this.mget(o);
|
|
682
|
+
for (const s of o.keys()) {
|
|
683
|
+
const r = this.getKeyWithoutPrefix(o[s], t);
|
|
684
|
+
const i = e[s];
|
|
685
|
+
yield [ r, i ];
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
} while (r !== "0");
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
async clear() {
|
|
692
|
+
try {
|
|
693
|
+
const t = await this.getMasterNodes();
|
|
694
|
+
await Promise.all(t.map((async t => {
|
|
695
|
+
if (!this._namespace && this._noNamespaceAffectsAll) {
|
|
696
|
+
await t.flushDb();
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
let e = "0";
|
|
700
|
+
const s = this._clearBatchSize;
|
|
701
|
+
const r = this._namespace ? `${this._namespace}${this._keyPrefixSeparator}*` : "*";
|
|
702
|
+
const i = [];
|
|
703
|
+
do {
|
|
704
|
+
const o = await t.scan(Number.parseInt(e, 10), {
|
|
705
|
+
MATCH: r,
|
|
706
|
+
COUNT: s,
|
|
707
|
+
TYPE: "string"
|
|
708
|
+
});
|
|
709
|
+
e = o.cursor.toString();
|
|
710
|
+
let {keys: n} = o;
|
|
711
|
+
if (n.length === 0) {
|
|
712
|
+
continue;
|
|
713
|
+
}
|
|
714
|
+
if (!this._namespace) {
|
|
715
|
+
n = n.filter((t => !t.includes(this._keyPrefixSeparator)));
|
|
716
|
+
}
|
|
717
|
+
i.push(this.clearWithClusterSupport(n));
|
|
718
|
+
} while (e !== "0");
|
|
719
|
+
await Promise.all(i);
|
|
720
|
+
})));
|
|
721
|
+
} catch (t) {
|
|
722
|
+
this.emit("error", t);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
async mget(t) {
|
|
726
|
+
const e = this.getSlotMap(t);
|
|
727
|
+
const s = new Map;
|
|
728
|
+
await Promise.all(Array.from(e.entries(), (async ([t, e]) => {
|
|
729
|
+
const r = await this.getSlotMaster(t);
|
|
730
|
+
const i = await r.mGet(e);
|
|
731
|
+
for (const [t, r] of i.entries()) {
|
|
732
|
+
s.set(e[t], r ?? void 0);
|
|
733
|
+
}
|
|
734
|
+
})));
|
|
735
|
+
return t.map((t => s.get(t)));
|
|
736
|
+
}
|
|
737
|
+
async clearWithClusterSupport(t) {
|
|
738
|
+
if (t.length > 0) {
|
|
739
|
+
const e = this.getSlotMap(t);
|
|
740
|
+
await Promise.all(Array.from(e.entries(), (async ([t, e]) => {
|
|
741
|
+
const s = await this.getSlotMaster(t);
|
|
742
|
+
return this._useUnlink ? s.unlink(e) : s.del(e);
|
|
743
|
+
})));
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
async getSlotMaster(t) {
|
|
747
|
+
const e = await this.getClient();
|
|
748
|
+
if (this.isCluster()) {
|
|
749
|
+
const s = e;
|
|
750
|
+
const r = s.slots[t].master;
|
|
751
|
+
return s.nodeClient(r);
|
|
752
|
+
}
|
|
753
|
+
return e;
|
|
754
|
+
}
|
|
755
|
+
getSlotMap(t) {
|
|
756
|
+
const e = new Map;
|
|
757
|
+
if (this.isCluster()) {
|
|
758
|
+
for (const s of t) {
|
|
759
|
+
const t = r(s);
|
|
760
|
+
const i = e.get(t) ?? [];
|
|
761
|
+
i.push(s);
|
|
762
|
+
e.set(t, i);
|
|
763
|
+
}
|
|
764
|
+
} else {
|
|
765
|
+
e.set(0, t);
|
|
766
|
+
}
|
|
767
|
+
return e;
|
|
768
|
+
}
|
|
769
|
+
isClientCluster(t) {
|
|
770
|
+
if (t.options === void 0 && t.scan === void 0) {
|
|
771
|
+
return true;
|
|
772
|
+
}
|
|
773
|
+
return false;
|
|
774
|
+
}
|
|
775
|
+
setOptions(t) {
|
|
776
|
+
if (!t) {
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
if (t.namespace) {
|
|
780
|
+
this._namespace = t.namespace;
|
|
781
|
+
}
|
|
782
|
+
if (t.keyPrefixSeparator !== void 0) {
|
|
783
|
+
this._keyPrefixSeparator = t.keyPrefixSeparator;
|
|
784
|
+
}
|
|
785
|
+
if (t.clearBatchSize !== void 0 && t.clearBatchSize > 0) {
|
|
786
|
+
this._clearBatchSize = t.clearBatchSize;
|
|
787
|
+
}
|
|
788
|
+
if (t.useUnlink !== void 0) {
|
|
789
|
+
this._useUnlink = t.useUnlink;
|
|
790
|
+
}
|
|
791
|
+
if (t.noNamespaceAffectsAll !== void 0) {
|
|
792
|
+
this._noNamespaceAffectsAll = t.noNamespaceAffectsAll;
|
|
793
|
+
}
|
|
794
|
+
if (t.throwOnConnectError !== void 0) {
|
|
795
|
+
this._throwOnConnectError = t.throwOnConnectError;
|
|
796
|
+
}
|
|
797
|
+
if (t.throwErrors !== void 0) {
|
|
798
|
+
this._throwErrors = t.throwErrors;
|
|
799
|
+
}
|
|
800
|
+
if (t.connectionTimeout !== void 0) {
|
|
801
|
+
this._connectionTimeout = t.connectionTimeout;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
initClient() {
|
|
805
|
+
this._client.on("connect", (() => {
|
|
806
|
+
this.emit("connect", this._client);
|
|
807
|
+
}));
|
|
808
|
+
this._client.on("disconnect", (() => {
|
|
809
|
+
this.emit("disconnect", this._client);
|
|
810
|
+
}));
|
|
811
|
+
this._client.on("reconnecting", (t => {
|
|
812
|
+
this.emit("reconnecting", t);
|
|
813
|
+
}));
|
|
814
|
+
}
|
|
815
|
+
async createTimeoutPromise(t) {
|
|
816
|
+
return new Promise(((e, s) => setTimeout((() => {
|
|
817
|
+
s(new Error(`Redis timed out after ${t}ms`));
|
|
818
|
+
}), t)));
|
|
819
|
+
}
|
|
820
|
+
};
|
|
821
|
+
|
|
822
|
+
function h(t, e) {
|
|
823
|
+
t ??= "redis://localhost:6379";
|
|
824
|
+
const r = new a(t, e);
|
|
825
|
+
const i = new s(r, {
|
|
826
|
+
namespace: e?.namespace,
|
|
827
|
+
useKeyPrefix: false
|
|
828
|
+
});
|
|
829
|
+
return i;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
export { s as Keyv, n as RedisErrorMessages, h as createKeyv, a as default, c as defaultReconnectStrategy };
|