memx 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,1124 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, { get: all[name], enumerable: true });
23
+ };
24
+
25
+ // src/decode.ts
26
+ var decode_exports = {};
27
+ __export(decode_exports, {
28
+ Decoder: () => Decoder
29
+ });
30
+
31
+ // src/constants.ts
32
+ var constants_exports = {};
33
+ __export(constants_exports, {
34
+ BUFFERS: () => BUFFERS,
35
+ DATA_TYPE: () => DATA_TYPE,
36
+ EMPTY_BUFFER: () => EMPTY_BUFFER,
37
+ FLAGS: () => FLAGS,
38
+ MAGIC: () => MAGIC,
39
+ OFFSETS: () => OFFSETS,
40
+ OPCODE: () => OPCODE,
41
+ STATUS: () => STATUS,
42
+ VBUCKET: () => VBUCKET
43
+ });
44
+ var EMPTY_BUFFER = Buffer.alloc(0);
45
+ var FLAGS = /* @__PURE__ */ ((FLAGS2) => {
46
+ FLAGS2[FLAGS2["BUFFER"] = 0] = "BUFFER";
47
+ FLAGS2[FLAGS2["BIGINT"] = 3402235904] = "BIGINT";
48
+ FLAGS2[FLAGS2["BOOLEAN"] = 3402235905] = "BOOLEAN";
49
+ FLAGS2[FLAGS2["NUMBER"] = 3402235906] = "NUMBER";
50
+ FLAGS2[FLAGS2["STRING"] = 3402235907] = "STRING";
51
+ FLAGS2[FLAGS2["NULL"] = 3402235918] = "NULL";
52
+ FLAGS2[FLAGS2["JSON"] = 3402235919] = "JSON";
53
+ FLAGS2[FLAGS2["UINT8ARRAY"] = 3402235920] = "UINT8ARRAY";
54
+ FLAGS2[FLAGS2["UINT8CLAMPEDARRAY"] = 3402235921] = "UINT8CLAMPEDARRAY";
55
+ FLAGS2[FLAGS2["UINT16ARRAY"] = 3402235922] = "UINT16ARRAY";
56
+ FLAGS2[FLAGS2["UINT32ARRAY"] = 3402235923] = "UINT32ARRAY";
57
+ FLAGS2[FLAGS2["INT8ARRAY"] = 3402235924] = "INT8ARRAY";
58
+ FLAGS2[FLAGS2["INT16ARRAY"] = 3402235925] = "INT16ARRAY";
59
+ FLAGS2[FLAGS2["INT32ARRAY"] = 3402235926] = "INT32ARRAY";
60
+ FLAGS2[FLAGS2["BIGUINT64ARRAY"] = 3402235927] = "BIGUINT64ARRAY";
61
+ FLAGS2[FLAGS2["BIGINT64ARRAY"] = 3402235928] = "BIGINT64ARRAY";
62
+ FLAGS2[FLAGS2["FLOAT32ARRAY"] = 3402235929] = "FLOAT32ARRAY";
63
+ FLAGS2[FLAGS2["FLOAT64ARRAY"] = 3402235930] = "FLOAT64ARRAY";
64
+ return FLAGS2;
65
+ })(FLAGS || {});
66
+ var BUFFERS = /* @__PURE__ */ ((BUFFERS2) => {
67
+ BUFFERS2[BUFFERS2["POOL_SIZE"] = 64] = "POOL_SIZE";
68
+ BUFFERS2[BUFFERS2["BUFFER_SIZE"] = 8192] = "BUFFER_SIZE";
69
+ BUFFERS2[BUFFERS2["HEADER_SIZE"] = 24] = "HEADER_SIZE";
70
+ BUFFERS2[BUFFERS2["KEY_SIZE"] = 250] = "KEY_SIZE";
71
+ BUFFERS2[BUFFERS2["KEY_TOO_BIG"] = 251] = "KEY_TOO_BIG";
72
+ return BUFFERS2;
73
+ })(BUFFERS || {});
74
+ var OFFSETS = /* @__PURE__ */ ((OFFSETS2) => {
75
+ OFFSETS2[OFFSETS2["MAGIC_$8"] = 0] = "MAGIC_$8";
76
+ OFFSETS2[OFFSETS2["OPCODE_$8"] = 1] = "OPCODE_$8";
77
+ OFFSETS2[OFFSETS2["KEY_LENGTH_$16"] = 2] = "KEY_LENGTH_$16";
78
+ OFFSETS2[OFFSETS2["EXTRAS_LENGTH_$8"] = 4] = "EXTRAS_LENGTH_$8";
79
+ OFFSETS2[OFFSETS2["DATA_TYPE_$8"] = 5] = "DATA_TYPE_$8";
80
+ OFFSETS2[OFFSETS2["STATUS_$16"] = 6] = "STATUS_$16";
81
+ OFFSETS2[OFFSETS2["BODY_LENGTH_$32"] = 8] = "BODY_LENGTH_$32";
82
+ OFFSETS2[OFFSETS2["SEQUENCE_$32"] = 12] = "SEQUENCE_$32";
83
+ OFFSETS2[OFFSETS2["CAS_$64"] = 16] = "CAS_$64";
84
+ OFFSETS2[OFFSETS2["BODY"] = 24] = "BODY";
85
+ return OFFSETS2;
86
+ })(OFFSETS || {});
87
+ var MAGIC = /* @__PURE__ */ ((MAGIC2) => {
88
+ MAGIC2[MAGIC2["REQUEST"] = 128] = "REQUEST";
89
+ MAGIC2[MAGIC2["RESPONSE"] = 129] = "RESPONSE";
90
+ return MAGIC2;
91
+ })(MAGIC || {});
92
+ var STATUS = /* @__PURE__ */ ((STATUS2) => {
93
+ STATUS2[STATUS2["OK"] = 0] = "OK";
94
+ STATUS2[STATUS2["KEY_NOT_FOUND"] = 1] = "KEY_NOT_FOUND";
95
+ STATUS2[STATUS2["KEY_EXISTS"] = 2] = "KEY_EXISTS";
96
+ STATUS2[STATUS2["TOO_LARGE"] = 3] = "TOO_LARGE";
97
+ STATUS2[STATUS2["INVALID_ARGS"] = 4] = "INVALID_ARGS";
98
+ STATUS2[STATUS2["ITEM_NOT_STORED"] = 5] = "ITEM_NOT_STORED";
99
+ STATUS2[STATUS2["NON_NUMERIC_VALUE"] = 6] = "NON_NUMERIC_VALUE";
100
+ STATUS2[STATUS2["WRONG_VBUCKET"] = 7] = "WRONG_VBUCKET";
101
+ STATUS2[STATUS2["AUTH_ERROR"] = 8] = "AUTH_ERROR";
102
+ STATUS2[STATUS2["AUTH_CONTINUE"] = 9] = "AUTH_CONTINUE";
103
+ STATUS2[STATUS2["UNKNOWN_COMMAND"] = 129] = "UNKNOWN_COMMAND";
104
+ STATUS2[STATUS2["OUT_OF_MEMORY"] = 130] = "OUT_OF_MEMORY";
105
+ STATUS2[STATUS2["NOT_SUPPORTED"] = 131] = "NOT_SUPPORTED";
106
+ STATUS2[STATUS2["INTERNAL_ERROR"] = 132] = "INTERNAL_ERROR";
107
+ STATUS2[STATUS2["BUSY"] = 133] = "BUSY";
108
+ STATUS2[STATUS2["TEMPORARY_FAILURE"] = 134] = "TEMPORARY_FAILURE";
109
+ return STATUS2;
110
+ })(STATUS || {});
111
+ var OPCODE = /* @__PURE__ */ ((OPCODE3) => {
112
+ OPCODE3[OPCODE3["GET"] = 0] = "GET";
113
+ OPCODE3[OPCODE3["SET"] = 1] = "SET";
114
+ OPCODE3[OPCODE3["ADD"] = 2] = "ADD";
115
+ OPCODE3[OPCODE3["REPLACE"] = 3] = "REPLACE";
116
+ OPCODE3[OPCODE3["DELETE"] = 4] = "DELETE";
117
+ OPCODE3[OPCODE3["INCREMENT"] = 5] = "INCREMENT";
118
+ OPCODE3[OPCODE3["DECREMENT"] = 6] = "DECREMENT";
119
+ OPCODE3[OPCODE3["QUIT"] = 7] = "QUIT";
120
+ OPCODE3[OPCODE3["FLUSH"] = 8] = "FLUSH";
121
+ OPCODE3[OPCODE3["NOOP"] = 10] = "NOOP";
122
+ OPCODE3[OPCODE3["VERSION"] = 11] = "VERSION";
123
+ OPCODE3[OPCODE3["APPEND"] = 14] = "APPEND";
124
+ OPCODE3[OPCODE3["PREPEND"] = 15] = "PREPEND";
125
+ OPCODE3[OPCODE3["STAT"] = 16] = "STAT";
126
+ OPCODE3[OPCODE3["TOUCH"] = 28] = "TOUCH";
127
+ OPCODE3[OPCODE3["GAT"] = 29] = "GAT";
128
+ return OPCODE3;
129
+ })(OPCODE || {});
130
+ var DATA_TYPE = /* @__PURE__ */ ((DATA_TYPE2) => {
131
+ DATA_TYPE2[DATA_TYPE2["RAW"] = 0] = "RAW";
132
+ return DATA_TYPE2;
133
+ })(DATA_TYPE || {});
134
+ var VBUCKET = /* @__PURE__ */ ((VBUCKET2) => {
135
+ VBUCKET2[VBUCKET2["NIL"] = 0] = "NIL";
136
+ return VBUCKET2;
137
+ })(VBUCKET || {});
138
+
139
+ // src/buffers.ts
140
+ var pool = new Array(64 /* POOL_SIZE */);
141
+ var offset = -1;
142
+ function allocateBuffer(size) {
143
+ if (size > 8192 /* BUFFER_SIZE */) {
144
+ const buffer2 = Buffer.allocUnsafeSlow(size);
145
+ buffer2.recycle = () => void 0;
146
+ return buffer2;
147
+ }
148
+ const buffer = offset >= 0 ? pool[offset--] : Buffer.allocUnsafeSlow(8192 /* BUFFER_SIZE */);
149
+ const recyclable = buffer.subarray(0, size);
150
+ let recycled = false;
151
+ recyclable.recycle = () => queueMicrotask(() => {
152
+ if (offset >= 64 /* POOL_SIZE */ || recycled)
153
+ return;
154
+ pool[++offset] = buffer;
155
+ recycled = true;
156
+ });
157
+ return recyclable;
158
+ }
159
+
160
+ // src/decode.ts
161
+ import assert from "assert";
162
+ var Decoder = class {
163
+ #consumer;
164
+ #header = Buffer.allocUnsafeSlow(24);
165
+ #body;
166
+ #pos = 0;
167
+ constructor(consumer) {
168
+ this.#consumer = consumer;
169
+ }
170
+ append(buffer, start, end) {
171
+ const header = this.#header;
172
+ while (start < end) {
173
+ if (this.#pos < 24) {
174
+ const copied = buffer.copy(header, this.#pos, start, end);
175
+ this.#pos += copied;
176
+ start += copied;
177
+ }
178
+ if (this.#pos < 24)
179
+ return;
180
+ let extras = EMPTY_BUFFER;
181
+ let key = EMPTY_BUFFER;
182
+ let value = EMPTY_BUFFER;
183
+ let recycle = () => void 0;
184
+ const bodyLength = header.readUInt32BE(8 /* BODY_LENGTH_$32 */);
185
+ if (bodyLength) {
186
+ const body = this.#body || (this.#body = allocateBuffer(bodyLength));
187
+ const copied = buffer.copy(body, this.#pos - 24, start, end);
188
+ this.#pos += copied;
189
+ start += copied;
190
+ if (this.#pos - 24 < body.length)
191
+ return;
192
+ const keyLength = header.readUInt16BE(2 /* KEY_LENGTH_$16 */);
193
+ const extrasLength = header.readUInt8(4 /* EXTRAS_LENGTH_$8 */);
194
+ const valueLength = bodyLength - keyLength - extrasLength;
195
+ key = keyLength ? body.subarray(extrasLength, extrasLength + keyLength) : EMPTY_BUFFER;
196
+ value = valueLength ? body.subarray(extrasLength + keyLength) : EMPTY_BUFFER;
197
+ extras = extrasLength ? body.subarray(0, extrasLength) : EMPTY_BUFFER;
198
+ recycle = () => void body.recycle();
199
+ }
200
+ const packet = {
201
+ opcode: header.readUInt8(1 /* OPCODE_$8 */),
202
+ status: header.readUInt16BE(6 /* STATUS_$16 */),
203
+ sequence: header.readUInt32BE(12 /* SEQUENCE_$32 */),
204
+ cas: header.readBigUInt64BE(16 /* CAS_$64 */),
205
+ extras,
206
+ key,
207
+ value,
208
+ recycle
209
+ };
210
+ const magic = header.readUInt8(0 /* MAGIC_$8 */);
211
+ const dataType = header.readUInt8(5 /* DATA_TYPE_$8 */);
212
+ assert.equal(magic, 129 /* RESPONSE */, "Invalid magic in header");
213
+ assert.equal(dataType, 0 /* RAW */, "Invalid data type in header");
214
+ this.#pos = 0;
215
+ this.#body = void 0;
216
+ this.#consumer(packet);
217
+ }
218
+ }
219
+ };
220
+
221
+ // src/encode.ts
222
+ var encode_exports = {};
223
+ __export(encode_exports, {
224
+ Encoder: () => Encoder
225
+ });
226
+ var CONSTANTS = /* @__PURE__ */ ((CONSTANTS2) => {
227
+ CONSTANTS2[CONSTANTS2["HEADER_SIZE"] = 24] = "HEADER_SIZE";
228
+ return CONSTANTS2;
229
+ })(CONSTANTS || {});
230
+ var Encoder = class {
231
+ encode(packet, seq = 0) {
232
+ const {
233
+ opcode,
234
+ sequence = seq,
235
+ cas = 0n,
236
+ extras = EMPTY_BUFFER,
237
+ extrasOffset = 0,
238
+ extrasLength = extras.length,
239
+ key = EMPTY_BUFFER,
240
+ keyOffset = 0,
241
+ keyLength = key.length,
242
+ value = EMPTY_BUFFER,
243
+ valueOffset = 0,
244
+ valueLength = value.length
245
+ } = packet;
246
+ const bodyLength = extrasLength + keyLength + valueLength;
247
+ const length = bodyLength + 24 /* HEADER_SIZE */;
248
+ const buffer = allocateBuffer(length);
249
+ buffer.writeUInt8(128 /* REQUEST */, 0 /* MAGIC_$8 */);
250
+ buffer.writeUInt8(opcode, 1 /* OPCODE_$8 */);
251
+ buffer.writeUInt16BE(keyLength, 2 /* KEY_LENGTH_$16 */);
252
+ buffer.writeUInt8(extrasLength, 4 /* EXTRAS_LENGTH_$8 */);
253
+ buffer.writeUInt8(0 /* RAW */, 5 /* DATA_TYPE_$8 */);
254
+ buffer.writeUInt16BE(0 /* NIL */, 6 /* STATUS_$16 */);
255
+ buffer.writeUInt32BE(bodyLength, 8 /* BODY_LENGTH_$32 */);
256
+ buffer.writeUInt32BE(sequence, 12 /* SEQUENCE_$32 */);
257
+ buffer.writeBigUInt64BE(cas, 16 /* CAS_$64 */);
258
+ let pos = 24;
259
+ if (extrasLength)
260
+ pos += extras.copy(buffer, pos, extrasOffset, extrasOffset + extrasLength);
261
+ if (keyLength)
262
+ pos += key.copy(buffer, pos, keyOffset, keyOffset + keyLength);
263
+ if (valueLength)
264
+ pos += value.copy(buffer, pos, valueOffset, valueOffset + valueLength);
265
+ return buffer;
266
+ }
267
+ };
268
+
269
+ // src/connection.ts
270
+ var connection_exports = {};
271
+ __export(connection_exports, {
272
+ Connection: () => Connection
273
+ });
274
+
275
+ // src/internals.ts
276
+ import assert2 from "assert";
277
+ import {
278
+ isUint8Array,
279
+ isUint8ClampedArray,
280
+ isUint16Array,
281
+ isUint32Array,
282
+ isInt8Array,
283
+ isInt16Array,
284
+ isInt32Array,
285
+ isBigUint64Array,
286
+ isBigInt64Array,
287
+ isFloat32Array,
288
+ isFloat64Array
289
+ } from "util/types";
290
+ var socketFinalizationRegistry = new FinalizationRegistry((socket) => {
291
+ if (!socket.destroyed)
292
+ socket.destroy();
293
+ });
294
+ function typedArrayFlags(value) {
295
+ const flags = isUint8Array(value) ? 3402235920 /* UINT8ARRAY */ : isUint8ClampedArray(value) ? 3402235921 /* UINT8CLAMPEDARRAY */ : isUint16Array(value) ? 3402235922 /* UINT16ARRAY */ : isUint32Array(value) ? 3402235923 /* UINT32ARRAY */ : isInt8Array(value) ? 3402235924 /* INT8ARRAY */ : isInt16Array(value) ? 3402235925 /* INT16ARRAY */ : isInt32Array(value) ? 3402235926 /* INT32ARRAY */ : isBigUint64Array(value) ? 3402235927 /* BIGUINT64ARRAY */ : isBigInt64Array(value) ? 3402235928 /* BIGINT64ARRAY */ : isFloat32Array(value) ? 3402235929 /* FLOAT32ARRAY */ : isFloat64Array(value) ? 3402235930 /* FLOAT64ARRAY */ : assert2.fail("Unsupported kind of TypedArray");
296
+ return flags;
297
+ }
298
+
299
+ // src/connection.ts
300
+ import assert3 from "assert";
301
+ import net from "net";
302
+ var Deferred = class {
303
+ #resolve;
304
+ #reject;
305
+ #packets = [];
306
+ promise;
307
+ opcode;
308
+ constructor(opcode) {
309
+ this.opcode = opcode;
310
+ this.promise = new Promise((resolve, reject) => {
311
+ this.#resolve = resolve;
312
+ this.#reject = reject;
313
+ });
314
+ }
315
+ append(packet) {
316
+ this.#packets.push(packet);
317
+ }
318
+ resolve(packet) {
319
+ this.#packets.push(packet);
320
+ this.#resolve(this.#packets);
321
+ }
322
+ reject(error) {
323
+ this.#reject(error);
324
+ }
325
+ };
326
+ var Connection = class {
327
+ #decoder = new Decoder((packet) => this.#receive(packet));
328
+ #encoder = new Encoder();
329
+ #buffer = Buffer.allocUnsafeSlow(8192 /* BUFFER_SIZE */);
330
+ #defers = /* @__PURE__ */ new Map();
331
+ #factory;
332
+ #socket;
333
+ #sequence = 0;
334
+ #timeout;
335
+ #host;
336
+ #port;
337
+ constructor(options) {
338
+ assert3(options, "No options specified");
339
+ const {
340
+ host,
341
+ port = 11211,
342
+ timeout = 1e3,
343
+ factory = net.connect
344
+ } = options;
345
+ this.#factory = factory;
346
+ assert3(host, "No host name specified");
347
+ assert3(port > 0 && port < 65536 && Math.floor(port) == port, `Invalid port ${port}`);
348
+ this.#timeout = timeout;
349
+ this.#host = host;
350
+ this.#port = port;
351
+ }
352
+ get connected() {
353
+ return !!this.#socket;
354
+ }
355
+ get host() {
356
+ return this.#host;
357
+ }
358
+ get port() {
359
+ return this.#port;
360
+ }
361
+ get timeout() {
362
+ return this.#timeout;
363
+ }
364
+ #connect() {
365
+ return this.#socket || (this.#socket = new Promise((resolve, reject) => {
366
+ const socket = this.#factory({
367
+ host: this.#host,
368
+ port: this.#port,
369
+ timeout: this.#timeout,
370
+ onread: {
371
+ buffer: this.#buffer,
372
+ callback: (bytes, buffer) => {
373
+ this.#decoder.append(buffer, 0, bytes);
374
+ return true;
375
+ }
376
+ }
377
+ });
378
+ socket.on("timeout", () => socket.destroy(new Error("Timeout")));
379
+ socket.on("error", reject);
380
+ socket.on("close", () => {
381
+ socketFinalizationRegistry.unregister(this);
382
+ this.#socket = void 0;
383
+ });
384
+ socket.on("connect", () => {
385
+ socketFinalizationRegistry.register(this, socket, this);
386
+ socket.off("error", reject);
387
+ socket.on("error", (error) => {
388
+ for (const deferred of this.#defers.values()) {
389
+ process.nextTick(() => deferred.reject(error));
390
+ }
391
+ this.#defers.clear();
392
+ this.#socket = void 0;
393
+ });
394
+ socket.unref();
395
+ resolve(socket);
396
+ });
397
+ }));
398
+ }
399
+ #receive(packet) {
400
+ const deferred = this.#defers.get(packet.sequence);
401
+ if (deferred) {
402
+ if (deferred.opcode === packet.opcode) {
403
+ if (packet.opcode === 16 /* STAT */ && packet.key.length !== 0) {
404
+ return deferred.append(packet);
405
+ }
406
+ return deferred.resolve(packet);
407
+ } else {
408
+ const sent = `0x${deferred.opcode.toString(16).padStart(2, "0")}`;
409
+ const received = `0x${packet.opcode.toString(16).padStart(2, "0")}`;
410
+ return deferred.reject(new Error(`Opcode mismatch (sent=${sent}, received=${received})`));
411
+ }
412
+ }
413
+ }
414
+ async send(packet) {
415
+ const sequence = ++this.#sequence;
416
+ const buffer = this.#encoder.encode(packet, sequence);
417
+ const deferred = new Deferred(packet.opcode);
418
+ this.#defers.set(sequence, deferred);
419
+ const socket = await this.#connect();
420
+ socket.write(buffer, (error) => {
421
+ buffer.recycle();
422
+ if (error)
423
+ return deferred.reject(error);
424
+ });
425
+ const timeout = setTimeout(() => deferred.reject(new Error("No response")), this.#timeout);
426
+ return deferred.promise.finally(() => {
427
+ clearTimeout(timeout);
428
+ this.#defers.delete(sequence);
429
+ });
430
+ }
431
+ async destroy() {
432
+ const socket = await this.#socket;
433
+ if (!socket)
434
+ return false;
435
+ return new Promise((resolve, reject) => {
436
+ socket.once("error", reject).once("close", resolve).destroy();
437
+ });
438
+ }
439
+ };
440
+
441
+ // src/server.ts
442
+ var statsBigInt = [
443
+ "auth_cmds",
444
+ "auth_errors",
445
+ "bytes",
446
+ "bytes_read",
447
+ "bytes_written",
448
+ "cas_badval",
449
+ "cas_hits",
450
+ "cas_misses",
451
+ "cmd_flush",
452
+ "cmd_get",
453
+ "cmd_set",
454
+ "cmd_touch",
455
+ "conn_yields",
456
+ "crawler_items_checked",
457
+ "crawler_reclaimed",
458
+ "curr_items",
459
+ "decr_hits",
460
+ "decr_misses",
461
+ "delete_hits",
462
+ "delete_misses",
463
+ "direct_reclaims",
464
+ "evicted_active",
465
+ "evicted_unfetched",
466
+ "evictions",
467
+ "expired_unfetched",
468
+ "get_expired",
469
+ "get_flushed",
470
+ "get_hits",
471
+ "get_misses",
472
+ "hash_bytes",
473
+ "idle_kicks",
474
+ "incr_hits",
475
+ "incr_misses",
476
+ "limit_maxbytes",
477
+ "listen_disabled_num",
478
+ "log_watcher_sent",
479
+ "log_watcher_skipped",
480
+ "log_watchers",
481
+ "log_worker_dropped",
482
+ "log_worker_written",
483
+ "lru_crawler_running",
484
+ "lru_crawler_starts",
485
+ "lru_maintainer_juggles",
486
+ "lrutail_reflocked",
487
+ "malloc_fails",
488
+ "moves_to_cold",
489
+ "moves_to_warm",
490
+ "moves_within_lru",
491
+ "read_buf_bytes",
492
+ "read_buf_bytes_free",
493
+ "read_buf_count",
494
+ "read_buf_oom",
495
+ "reclaimed",
496
+ "rejected_connections",
497
+ "response_obj_bytes",
498
+ "response_obj_count",
499
+ "response_obj_oom",
500
+ "round_robin_fallback",
501
+ "slab_reassign_busy_deletes",
502
+ "slab_reassign_busy_items",
503
+ "slab_reassign_chunk_rescues",
504
+ "slab_reassign_evictions_nomem",
505
+ "slab_reassign_inline_reclaim",
506
+ "slab_reassign_rescues",
507
+ "slabs_moved",
508
+ "store_no_memory",
509
+ "store_too_large",
510
+ "time_in_listen_disabled_us",
511
+ "total_items",
512
+ "touch_hits",
513
+ "touch_misses",
514
+ "unexpected_napi_ids"
515
+ ];
516
+ var statsNumber = [
517
+ "connection_structures",
518
+ "curr_connections",
519
+ "hash_power_level",
520
+ "max_connections",
521
+ "pid",
522
+ "pointer_size",
523
+ "reserved_fds",
524
+ "slab_global_page_pool",
525
+ "threads",
526
+ "time",
527
+ "total_connections",
528
+ "uptime"
529
+ ];
530
+ var statsBoolean = ["accepting_conns", "hash_is_expanding", "slab_reassign_running"];
531
+ var statsMicroseconds = ["rusage_system", "rusage_user"];
532
+ function injectStats(key, value, stats) {
533
+ if (!key)
534
+ return stats;
535
+ if (statsBigInt.includes(key)) {
536
+ stats[key] = BigInt(value);
537
+ } else if (statsNumber.includes(key)) {
538
+ stats[key] = Number(value);
539
+ } else if (statsBoolean.includes(key)) {
540
+ stats[key] = !!Number(value);
541
+ } else if (statsMicroseconds.includes(key)) {
542
+ const splits = value.split(".");
543
+ stats[key] = BigInt(`${splits[0]}${splits[1].padEnd(6, "0")}`);
544
+ } else {
545
+ stats[key] = value;
546
+ }
547
+ return stats;
548
+ }
549
+ function fail(packet, key) {
550
+ const message = packet.value.toString("utf-8") || "Unknown Error";
551
+ const status = STATUS[packet.status] || `0x${packet.status.toString(16).padStart(4, "0")}`;
552
+ throw new Error(`${message} (status=${status}${key ? `, key=${key}` : ""})`);
553
+ }
554
+ var ServerAdapter = class {
555
+ #buffer = Buffer.alloc(251 /* KEY_TOO_BIG */ + 20);
556
+ #connection;
557
+ #ttl;
558
+ #id;
559
+ constructor(options) {
560
+ this.#connection = new Connection(options);
561
+ this.#ttl = options.ttl || 0;
562
+ this.#id = `${this.#connection.host}:${this.#connection.port}`;
563
+ }
564
+ get connected() {
565
+ return this.#connection.connected;
566
+ }
567
+ get host() {
568
+ return this.#connection.host;
569
+ }
570
+ get port() {
571
+ return this.#connection.port;
572
+ }
573
+ get timeout() {
574
+ return this.#connection.timeout;
575
+ }
576
+ get ttl() {
577
+ return this.#ttl;
578
+ }
579
+ get id() {
580
+ return this.#id;
581
+ }
582
+ #writeKey(key, offset2 = 0) {
583
+ const keyLength = this.#buffer.write(key, offset2, 251 /* KEY_TOO_BIG */, "utf-8");
584
+ if (keyLength > 250 /* KEY_SIZE */)
585
+ throw new Error(`Key too long (len=${keyLength})`);
586
+ return keyLength;
587
+ }
588
+ async get(key, options = {}) {
589
+ const { ttl } = options;
590
+ let keyOffset = 0;
591
+ if (ttl)
592
+ keyOffset = this.#buffer.writeUInt32BE(ttl);
593
+ const keyLength = this.#writeKey(key, keyOffset);
594
+ const [response] = await this.#connection.send({
595
+ opcode: ttl ? 29 /* GAT */ : 0 /* GET */,
596
+ extras: this.#buffer,
597
+ extrasOffset: 0,
598
+ extrasLength: keyOffset,
599
+ key: this.#buffer,
600
+ keyOffset,
601
+ keyLength
602
+ });
603
+ switch (response.status) {
604
+ case 0 /* OK */:
605
+ return {
606
+ value: response.value,
607
+ flags: response.extras.readUInt32BE(),
608
+ cas: response.cas,
609
+ recycle: () => response.recycle()
610
+ };
611
+ case 1 /* KEY_NOT_FOUND */:
612
+ return;
613
+ default:
614
+ fail(response, key);
615
+ }
616
+ }
617
+ async touch(key, options = {}) {
618
+ const { ttl = this.#ttl } = options;
619
+ const keyOffset = this.#buffer.writeUInt32BE(ttl);
620
+ const keyLength = this.#writeKey(key, keyOffset);
621
+ const [response] = await this.#connection.send({
622
+ opcode: 28 /* TOUCH */,
623
+ extras: this.#buffer,
624
+ extrasOffset: 0,
625
+ extrasLength: keyOffset,
626
+ key: this.#buffer,
627
+ keyOffset,
628
+ keyLength
629
+ });
630
+ try {
631
+ switch (response.status) {
632
+ case 0 /* OK */:
633
+ return true;
634
+ case 1 /* KEY_NOT_FOUND */:
635
+ return false;
636
+ default:
637
+ fail(response, key);
638
+ }
639
+ } finally {
640
+ response.recycle();
641
+ }
642
+ }
643
+ async #sar(opcode, key, value, options) {
644
+ const { flags = 0, cas = 0n, ttl = this.#ttl } = options;
645
+ let keyOffset;
646
+ keyOffset = this.#buffer.writeUInt32BE(flags);
647
+ keyOffset = this.#buffer.writeUInt32BE(ttl, keyOffset);
648
+ const keyLength = this.#writeKey(key, keyOffset);
649
+ const [response] = await this.#connection.send({
650
+ opcode,
651
+ cas,
652
+ extras: this.#buffer,
653
+ extrasOffset: 0,
654
+ extrasLength: keyOffset,
655
+ key: this.#buffer,
656
+ keyOffset,
657
+ keyLength,
658
+ value
659
+ });
660
+ try {
661
+ switch (response.status) {
662
+ case 0 /* OK */:
663
+ return response.cas;
664
+ case 1 /* KEY_NOT_FOUND */:
665
+ case 2 /* KEY_EXISTS */:
666
+ return;
667
+ default:
668
+ fail(response, key);
669
+ }
670
+ } finally {
671
+ response.recycle();
672
+ }
673
+ }
674
+ set(key, value, options = {}) {
675
+ return this.#sar(1 /* SET */, key, value, options);
676
+ }
677
+ add(key, value, options = {}) {
678
+ return this.#sar(2 /* ADD */, key, value, options);
679
+ }
680
+ replace(key, value, options = {}) {
681
+ return this.#sar(3 /* REPLACE */, key, value, options);
682
+ }
683
+ async #pend(opcode, key, value, options) {
684
+ const { cas = 0n } = options;
685
+ const keyLength = this.#writeKey(key);
686
+ const [response] = await this.#connection.send({
687
+ opcode,
688
+ cas,
689
+ key: Buffer.from(key, "utf-8"),
690
+ keyOffset: 0,
691
+ keyLength,
692
+ value
693
+ });
694
+ try {
695
+ switch (response.status) {
696
+ case 0 /* OK */:
697
+ return true;
698
+ case 5 /* ITEM_NOT_STORED */:
699
+ case 2 /* KEY_EXISTS */:
700
+ return false;
701
+ default:
702
+ fail(response, key);
703
+ }
704
+ } finally {
705
+ response.recycle();
706
+ }
707
+ }
708
+ append(key, value, options = {}) {
709
+ return this.#pend(14 /* APPEND */, key, value, options);
710
+ }
711
+ prepend(key, value, options = {}) {
712
+ return this.#pend(15 /* PREPEND */, key, value, options);
713
+ }
714
+ async #counter(opcode, key, delta, options) {
715
+ const {
716
+ initial,
717
+ cas = 0n,
718
+ ttl = this.#ttl
719
+ } = options;
720
+ let keyOffset;
721
+ keyOffset = this.#buffer.writeBigUInt64BE(BigInt(delta));
722
+ keyOffset = this.#buffer.writeBigUInt64BE(BigInt(initial || 0n), keyOffset);
723
+ keyOffset = this.#buffer.writeUInt32BE(initial == void 0 ? 4294967295 : ttl, keyOffset);
724
+ const keyLength = this.#writeKey(key, keyOffset);
725
+ const [response] = await this.#connection.send({
726
+ opcode,
727
+ extras: this.#buffer,
728
+ extrasOffset: 0,
729
+ extrasLength: keyOffset,
730
+ key: this.#buffer,
731
+ keyOffset,
732
+ keyLength,
733
+ cas
734
+ });
735
+ try {
736
+ switch (response.status) {
737
+ case 0 /* OK */:
738
+ return {
739
+ value: response.value.readBigUInt64BE(0),
740
+ cas: response.cas
741
+ };
742
+ case 1 /* KEY_NOT_FOUND */:
743
+ case 2 /* KEY_EXISTS */:
744
+ return;
745
+ default:
746
+ fail(response, key);
747
+ }
748
+ } finally {
749
+ response.recycle();
750
+ }
751
+ }
752
+ increment(key, delta = 1, options = {}) {
753
+ return this.#counter(5 /* INCREMENT */, key, delta, options);
754
+ }
755
+ decrement(key, delta = 1, options = {}) {
756
+ return this.#counter(6 /* DECREMENT */, key, delta, options);
757
+ }
758
+ async delete(key, options = {}) {
759
+ const { cas = 0n } = options;
760
+ const keyLength = this.#writeKey(key);
761
+ const [response] = await this.#connection.send({
762
+ opcode: 4 /* DELETE */,
763
+ key: this.#buffer,
764
+ keyOffset: 0,
765
+ keyLength,
766
+ cas
767
+ });
768
+ try {
769
+ switch (response.status) {
770
+ case 0 /* OK */:
771
+ return true;
772
+ case 1 /* KEY_NOT_FOUND */:
773
+ case 2 /* KEY_EXISTS */:
774
+ return false;
775
+ default:
776
+ fail(response, key);
777
+ }
778
+ } finally {
779
+ response.recycle();
780
+ }
781
+ }
782
+ async flush(ttl = 0) {
783
+ const extrasLength = ttl ? this.#buffer.writeUInt32BE(ttl) : 0;
784
+ const [response] = await this.#connection.send({
785
+ opcode: 8 /* FLUSH */,
786
+ extras: this.#buffer,
787
+ extrasOffset: 0,
788
+ extrasLength
789
+ });
790
+ try {
791
+ switch (response.status) {
792
+ case 0 /* OK */:
793
+ return;
794
+ default:
795
+ fail(response);
796
+ }
797
+ } finally {
798
+ response.recycle();
799
+ }
800
+ }
801
+ async noop() {
802
+ const [response] = await this.#connection.send({
803
+ opcode: 10 /* NOOP */
804
+ });
805
+ try {
806
+ switch (response.status) {
807
+ case 0 /* OK */:
808
+ return;
809
+ default:
810
+ fail(response);
811
+ }
812
+ } finally {
813
+ response.recycle();
814
+ }
815
+ }
816
+ async quit() {
817
+ const [response] = await this.#connection.send({
818
+ opcode: 7 /* QUIT */
819
+ });
820
+ try {
821
+ switch (response.status) {
822
+ case 0 /* OK */:
823
+ return;
824
+ default:
825
+ fail(response);
826
+ }
827
+ } finally {
828
+ response.recycle();
829
+ }
830
+ }
831
+ async version() {
832
+ const [response] = await this.#connection.send({
833
+ opcode: 11 /* VERSION */
834
+ });
835
+ try {
836
+ switch (response.status) {
837
+ case 0 /* OK */:
838
+ return { [this.#id]: response.value.toString("utf-8") };
839
+ default:
840
+ fail(response);
841
+ }
842
+ } finally {
843
+ response.recycle();
844
+ }
845
+ }
846
+ async stats() {
847
+ const responses = await this.#connection.send({
848
+ opcode: 16 /* STAT */
849
+ });
850
+ const stats = responses.reduce((result, packet) => {
851
+ try {
852
+ if (packet.status !== 0 /* OK */)
853
+ fail(packet);
854
+ const key = packet.key.toString("utf-8");
855
+ const value = packet.value.toString("utf-8");
856
+ return injectStats(key, value, result);
857
+ } finally {
858
+ packet.recycle();
859
+ }
860
+ }, {});
861
+ return { [this.#id]: stats };
862
+ }
863
+ };
864
+
865
+ // src/cluster.ts
866
+ function parseHosts(hosts) {
867
+ const result = [];
868
+ if (!hosts)
869
+ return result;
870
+ for (const part of hosts.split(",")) {
871
+ const [host, p] = part.split(":");
872
+ const port = parseInt(p) || void 0;
873
+ result.push({ host, port });
874
+ }
875
+ return result;
876
+ }
877
+ var ClusterAdapter = class {
878
+ servers;
879
+ constructor(serversOrOptions) {
880
+ if (Array.isArray(serversOrOptions)) {
881
+ this.servers = [...serversOrOptions];
882
+ } else if (serversOrOptions) {
883
+ const { ttl, timeout, hosts: defs } = serversOrOptions;
884
+ const hosts = [];
885
+ if (Array.isArray(defs)) {
886
+ defs.forEach((def) => {
887
+ if (typeof def === "string")
888
+ hosts.push(...parseHosts(def));
889
+ else
890
+ hosts.push(__spreadValues({ port: 11211 }, def));
891
+ });
892
+ } else {
893
+ hosts.push(...parseHosts(defs));
894
+ }
895
+ this.servers = hosts.map((host) => new ServerAdapter(__spreadValues({ ttl, timeout }, host)));
896
+ } else {
897
+ const hosts = parseHosts(process.env.MEMCACHED_HOSTS);
898
+ const ttl = process.env.MEMCACHED_TTL && parseInt(process.env.MEMCACHED_TTL) || void 0;
899
+ const timeout = process.env.MEMCACHED_TIMEOUT && parseInt(process.env.MEMCACHED_TIMEOUT) || void 0;
900
+ this.servers = hosts.map((host) => new ServerAdapter(__spreadValues({ ttl, timeout }, host)));
901
+ }
902
+ if (this.servers.length < 1)
903
+ throw new Error("No hosts configured");
904
+ if (this.servers.length === 1)
905
+ this.server = () => this.servers[0];
906
+ Object.freeze(this.servers);
907
+ }
908
+ server(key) {
909
+ const length = key.length;
910
+ let hash = 0;
911
+ for (let i = 0; i < length; i++)
912
+ hash = hash * 31 + key.charCodeAt(i);
913
+ return this.servers[hash % this.servers.length];
914
+ }
915
+ get(key, options) {
916
+ return this.server(key).get(key, options);
917
+ }
918
+ touch(key, options) {
919
+ return this.server(key).touch(key, options);
920
+ }
921
+ set(key, value, options) {
922
+ return this.server(key).set(key, value, options);
923
+ }
924
+ add(key, value, options) {
925
+ return this.server(key).add(key, value, options);
926
+ }
927
+ replace(key, value, options) {
928
+ return this.server(key).replace(key, value, options);
929
+ }
930
+ append(key, value, options) {
931
+ return this.server(key).append(key, value, options);
932
+ }
933
+ prepend(key, value, options) {
934
+ return this.server(key).prepend(key, value, options);
935
+ }
936
+ increment(key, delta, options) {
937
+ return this.server(key).increment(key, delta, options);
938
+ }
939
+ decrement(key, delta, options) {
940
+ return this.server(key).decrement(key, delta, options);
941
+ }
942
+ delete(key, options) {
943
+ return this.server(key).delete(key, options);
944
+ }
945
+ async flush(ttl) {
946
+ await Promise.all(this.servers.map((server) => server.flush(ttl)));
947
+ }
948
+ async noop() {
949
+ await Promise.all(this.servers.map((server) => server.noop()));
950
+ }
951
+ async quit() {
952
+ await Promise.all(this.servers.map((server) => server.quit()));
953
+ }
954
+ async version() {
955
+ const versions = await Promise.all(this.servers.map((server) => server.version()));
956
+ return versions.reduce((v1, v2) => __spreadValues(__spreadValues({}, v1), v2));
957
+ }
958
+ async stats() {
959
+ const stats = await Promise.all(this.servers.map((server) => server.stats()));
960
+ return stats.reduce((v1, v2) => __spreadValues(__spreadValues({}, v1), v2));
961
+ }
962
+ };
963
+
964
+ // src/client.ts
965
+ import assert4 from "assert";
966
+ import { isTypedArray } from "util/types";
967
+ function toBuffer(value, options) {
968
+ if (Buffer.isBuffer(value))
969
+ return [value, __spreadProps(__spreadValues({}, options), { flags: 0 /* BUFFER */ })];
970
+ switch (typeof value) {
971
+ case "bigint":
972
+ return [Buffer.from(value.toString(), "utf-8"), __spreadProps(__spreadValues({}, options), { flags: 3402235904 /* BIGINT */ })];
973
+ case "boolean":
974
+ return [Buffer.alloc(1, value ? 255 : 0), __spreadProps(__spreadValues({}, options), { flags: 3402235905 /* BOOLEAN */ })];
975
+ case "number":
976
+ return [Buffer.from(value.toString(), "utf-8"), __spreadProps(__spreadValues({}, options), { flags: 3402235906 /* NUMBER */ })];
977
+ case "string":
978
+ return [Buffer.from(value, "utf-8"), __spreadProps(__spreadValues({}, options), { flags: 3402235907 /* STRING */ })];
979
+ case "object":
980
+ break;
981
+ default:
982
+ assert4.fail(`Unable to store value of type "${typeof value}"`);
983
+ }
984
+ if (isTypedArray(value)) {
985
+ const flags = typedArrayFlags(value);
986
+ const buffer = Buffer.from(value.buffer, value.byteOffset, value.byteLength);
987
+ return [buffer, __spreadProps(__spreadValues({}, options), { flags })];
988
+ }
989
+ if (value === null)
990
+ return [EMPTY_BUFFER, __spreadProps(__spreadValues({}, options), { flags: 3402235918 /* NULL */ })];
991
+ return [Buffer.from(JSON.stringify(value), "utf-8"), __spreadProps(__spreadValues({}, options), { flags: 3402235919 /* JSON */ })];
992
+ }
993
+ function makeTypedArray(constructor, source, bytesPerValue) {
994
+ const clone = Buffer.from(source);
995
+ const { buffer, byteOffset, byteLength } = clone;
996
+ return new constructor(buffer, byteOffset, byteLength / bytesPerValue);
997
+ }
998
+ var Client = class {
999
+ #adapter;
1000
+ constructor(adapterOrOptions) {
1001
+ if (!adapterOrOptions) {
1002
+ this.#adapter = new ClusterAdapter();
1003
+ } else if ("get" in adapterOrOptions) {
1004
+ this.#adapter = adapterOrOptions;
1005
+ } else if ("hosts" in adapterOrOptions) {
1006
+ this.#adapter = new ClusterAdapter(adapterOrOptions);
1007
+ }
1008
+ assert4(this.#adapter, "Invalid client constructor arguments");
1009
+ }
1010
+ get adapter() {
1011
+ return this.#adapter;
1012
+ }
1013
+ async get(key, options) {
1014
+ const result = await this.#adapter.get(key, options);
1015
+ if (!result)
1016
+ return;
1017
+ try {
1018
+ const { flags, value, cas } = result;
1019
+ switch (flags) {
1020
+ case 3402235904 /* BIGINT */:
1021
+ return { value: BigInt(value.toString("utf-8")), cas };
1022
+ case 3402235905 /* BOOLEAN */:
1023
+ return { value: !!value[0], cas };
1024
+ case 3402235906 /* NUMBER */:
1025
+ return { value: Number(value.toString("utf-8")), cas };
1026
+ case 3402235907 /* STRING */:
1027
+ return { value: value.toString("utf-8"), cas };
1028
+ case 3402235918 /* NULL */:
1029
+ return { value: null, cas };
1030
+ case 3402235919 /* JSON */:
1031
+ return { value: JSON.parse(value.toString("utf-8")), cas };
1032
+ case 3402235920 /* UINT8ARRAY */:
1033
+ return { value: makeTypedArray(Uint8Array, value, 1), cas };
1034
+ case 3402235921 /* UINT8CLAMPEDARRAY */:
1035
+ return { value: makeTypedArray(Uint8ClampedArray, value, 1), cas };
1036
+ case 3402235922 /* UINT16ARRAY */:
1037
+ return { value: makeTypedArray(Uint16Array, value, 2), cas };
1038
+ case 3402235923 /* UINT32ARRAY */:
1039
+ return { value: makeTypedArray(Uint32Array, value, 4), cas };
1040
+ case 3402235924 /* INT8ARRAY */:
1041
+ return { value: makeTypedArray(Int8Array, value, 1), cas };
1042
+ case 3402235925 /* INT16ARRAY */:
1043
+ return { value: makeTypedArray(Int16Array, value, 2), cas };
1044
+ case 3402235926 /* INT32ARRAY */:
1045
+ return { value: makeTypedArray(Int32Array, value, 4), cas };
1046
+ case 3402235927 /* BIGUINT64ARRAY */:
1047
+ return { value: makeTypedArray(BigUint64Array, value, 8), cas };
1048
+ case 3402235928 /* BIGINT64ARRAY */:
1049
+ return { value: makeTypedArray(BigInt64Array, value, 8), cas };
1050
+ case 3402235929 /* FLOAT32ARRAY */:
1051
+ return { value: makeTypedArray(Float32Array, value, 4), cas };
1052
+ case 3402235930 /* FLOAT64ARRAY */:
1053
+ return { value: makeTypedArray(Float64Array, value, 8), cas };
1054
+ case 0 /* BUFFER */:
1055
+ default:
1056
+ return { value: Buffer.from(value), cas };
1057
+ }
1058
+ } finally {
1059
+ result.recycle();
1060
+ }
1061
+ }
1062
+ async set(key, value, options) {
1063
+ return this.#adapter.set(key, ...toBuffer(value, options));
1064
+ }
1065
+ async add(key, value, options) {
1066
+ return this.#adapter.add(key, ...toBuffer(value, options));
1067
+ }
1068
+ async replace(key, value, options) {
1069
+ return this.#adapter.replace(key, ...toBuffer(value, options));
1070
+ }
1071
+ append(key, value, options) {
1072
+ return this.#adapter.append(key, ...toBuffer(value, options));
1073
+ }
1074
+ prepend(key, value, options) {
1075
+ return this.#adapter.prepend(key, ...toBuffer(value, options));
1076
+ }
1077
+ async increment(key, delta, options) {
1078
+ const counter = await this.#adapter.increment(key, delta, options);
1079
+ if (counter && options && options.initial !== void 0 && counter.value === BigInt(options.initial)) {
1080
+ const cas = await this.replace(key, counter.value, { cas: counter.cas, ttl: options.ttl });
1081
+ counter.cas = cas ?? counter.cas;
1082
+ }
1083
+ return counter;
1084
+ }
1085
+ async decrement(key, delta, options) {
1086
+ const counter = await this.#adapter.decrement(key, delta, options);
1087
+ if (counter && options && options.initial !== void 0 && counter.value === BigInt(options.initial)) {
1088
+ const cas = await this.replace(key, counter.value, { cas: counter.cas, ttl: options.ttl });
1089
+ counter.cas = cas ?? counter.cas;
1090
+ }
1091
+ return counter;
1092
+ }
1093
+ touch(key, options) {
1094
+ return this.#adapter.touch(key, options);
1095
+ }
1096
+ delete(key, options) {
1097
+ return this.#adapter.delete(key, options);
1098
+ }
1099
+ flush(ttl) {
1100
+ return this.#adapter.flush(ttl);
1101
+ }
1102
+ noop() {
1103
+ return this.#adapter.noop();
1104
+ }
1105
+ quit() {
1106
+ return this.#adapter.quit();
1107
+ }
1108
+ version() {
1109
+ return this.#adapter.version();
1110
+ }
1111
+ stats() {
1112
+ return this.#adapter.stats();
1113
+ }
1114
+ };
1115
+ export {
1116
+ Client,
1117
+ ClusterAdapter,
1118
+ ServerAdapter,
1119
+ connection_exports as connection,
1120
+ constants_exports as constants,
1121
+ decode_exports as decode,
1122
+ encode_exports as encode
1123
+ };
1124
+ //# sourceMappingURL=index.mjs.map