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/src/types.ts ADDED
@@ -0,0 +1,263 @@
1
+ export interface AdapterResult {
2
+ value: Buffer
3
+ flags: number,
4
+ cas: bigint
5
+ recycle: () => void
6
+ }
7
+
8
+ export interface Counter {
9
+ value: bigint,
10
+ cas: bigint
11
+ }
12
+
13
+ export interface Stats {
14
+ /** Process id of this server process (32u) */
15
+ pid: number
16
+ /** Number of secs since the server started (32u) */
17
+ uptime: number
18
+ /** current UNIX time according to the server (32u) */
19
+ time: number
20
+ /** Version string of this server (string) */
21
+ version: string
22
+ /** Default size of pointers on the host OS (generally 32 or 64) (32) */
23
+ pointer_size: number
24
+ /** Accumulated user time for this process (microseconds) (32u.32u) */
25
+ rusage_user: bigint
26
+ /** Accumulated system time for this process (microseconds) (32u.32u) */
27
+ rusage_system: bigint
28
+ /** Current number of items stored (64u) */
29
+ curr_items: bigint
30
+ /** Total number of items stored since the server started (64u) */
31
+ total_items: bigint
32
+ /** Current number of bytes used to store items (64u) */
33
+ bytes: bigint
34
+ /** Max number of simultaneous connections (32u) */
35
+ max_connections: number
36
+ /** Number of open connections (32u) */
37
+ curr_connections: number
38
+ /** Total number of connections opened since the server started running (32u) */
39
+ total_connections: number
40
+ /** Conns rejected in maxconns_fast mode (64u) */
41
+ rejected_connections: bigint
42
+ /** Number of connection structures allocated by the server (32u) */
43
+ connection_structures: number
44
+ /** Connections closed by lack of memory (64u) */
45
+ response_obj_oom: bigint
46
+ /** Total response objects in use (64u) */
47
+ response_obj_count: bigint
48
+ /** Total bytes used for resp. objects. is a subset of bytes from read_buf_bytes (64u) */
49
+ response_obj_bytes: bigint
50
+ /** Total read/resp buffers allocated (64u) */
51
+ read_buf_count: bigint
52
+ /** Total read/resp buffer bytes allocated (64u) */
53
+ read_buf_bytes: bigint
54
+ /** Total read/resp buffer bytes cached (64u) */
55
+ read_buf_bytes_free: bigint
56
+ /** Connections closed by lack of memory (64u) */
57
+ read_buf_oom: bigint
58
+ /** Number of misc fds used internally (32u) */
59
+ reserved_fds: number
60
+ /** Cumulative number of retrieval reqs (64u) */
61
+ cmd_get: bigint
62
+ /** Cumulative number of storage reqs (64u) */
63
+ cmd_set: bigint
64
+ /** Cumulative number of flush reqs (64u) */
65
+ cmd_flush: bigint
66
+ /** Cumulative number of touch reqs (64u) */
67
+ cmd_touch: bigint
68
+ /** Number of keys that have been requested and found present (64u) */
69
+ get_hits: bigint
70
+ /** Number of items that have been requested and not found (64u) */
71
+ get_misses: bigint
72
+ /** Number of items that have been requested but had already expired (64u) */
73
+ get_expired: bigint
74
+ /** Number of items that have been requested but have been flushed via flush_all (64u) */
75
+ get_flushed: bigint
76
+ /** Number of deletions reqs for missing keys (64u) */
77
+ delete_misses: bigint
78
+ /** Number of deletion reqs resulting in an item being removed (64u) */
79
+ delete_hits: bigint
80
+ /** Number of incr reqs against missing keys (64u) */
81
+ incr_misses: bigint
82
+ /** Number of successful incr reqs (64u) */
83
+ incr_hits: bigint
84
+ /** Number of decr reqs against missing keys (64u) */
85
+ decr_misses: bigint
86
+ /** Number of successful decr reqs (64u) */
87
+ decr_hits: bigint
88
+ /** Number of CAS reqs against missing keys (64u) */
89
+ cas_misses: bigint
90
+ /** Number of successful CAS reqs (64u) */
91
+ cas_hits: bigint
92
+ /** Number of CAS reqs for which a key was found, but the CAS value did not match (64u) */
93
+ cas_badval: bigint
94
+ /** Number of keys that have been touched with a new expiration time (64u) */
95
+ touch_hits: bigint
96
+ /** Number of items that have been touched and not found (64u) */
97
+ touch_misses: bigint
98
+ /** Number of rejected storage requests caused by attempting to write a value larger than the -I limit (64u) */
99
+ store_too_large: bigint
100
+ /** Number of rejected storage requests caused by exhaustion of the -m memory limit (relevant when -M is used) (64u) */
101
+ store_no_memory: bigint
102
+ /** Number of authentication commands handled, success or failure (64u) */
103
+ auth_cmds: bigint
104
+ /** Number of failed authentications (64u) */
105
+ auth_errors: bigint
106
+ /** Number of connections closed due to reaching their idle timeout (64u) */
107
+ idle_kicks: bigint
108
+ /** Number of valid items removed from cache to free memory for new items (64u) */
109
+ evictions: bigint
110
+ /** Number of times an entry was stored using memory from an expired entry (64u) */
111
+ reclaimed: bigint
112
+ /** Total number of bytes read by this server from network (64u) */
113
+ bytes_read: bigint
114
+ /** Total number of bytes sent by this server to network (64u) */
115
+ bytes_written: bigint
116
+ /** Number of bytes this server is allowed to use for storage (size_t) */
117
+ limit_maxbytes: bigint
118
+ /** Whether or not server is accepting conns (bool) */
119
+ accepting_conns: boolean
120
+ /** Number of times server has stopped accepting new connections (maxconns) (64u) */
121
+ listen_disabled_num: bigint
122
+ /** Number of microseconds in maxconns (64u) */
123
+ time_in_listen_disabled_us: bigint
124
+ /** Number of worker threads requested (see doc/threads.txt) (32u) */
125
+ threads: number
126
+ /** Number of times any connection yielded to another due to hitting the -R limit (64u) */
127
+ conn_yields: bigint
128
+ /** Current size multiplier for hash table (32u) */
129
+ hash_power_level: number
130
+ /** Bytes currently used by hash tables (64u) */
131
+ hash_bytes: bigint
132
+ /** Indicates if the hash table is being grown to a new size (bool) */
133
+ hash_is_expanding: boolean
134
+ /** Items pulled from LRU that were never touched by get/incr/append/etc before expiring (64u) */
135
+ expired_unfetched: bigint
136
+ /** Items evicted from LRU that were never touched by get/incr/append/etc (64u) */
137
+ evicted_unfetched: bigint
138
+ /** Items evicted from LRU that had been hit recently but did not jump to top of LRU (64u) */
139
+ evicted_active: bigint
140
+ /** If a slab page is being moved (bool) */
141
+ slab_reassign_running: boolean
142
+ /** Total slab pages moved (64u) */
143
+ slabs_moved: bigint
144
+ /** Total items freed by LRU Crawler (64u) */
145
+ crawler_reclaimed: bigint
146
+ /** Total items examined by LRU Crawler (64u) */
147
+ crawler_items_checked: bigint
148
+ /** Times LRU tail was found with active ref. Items can be evicted to avoid OOM errors (64u) */
149
+ lrutail_reflocked: bigint
150
+ /** Items moved from HOT/WARM to COLD LRU's (64u) */
151
+ moves_to_cold: bigint
152
+ /** Items moved from COLD to WARM LRU (64u) */
153
+ moves_to_warm: bigint
154
+ /** Items reshuffled within HOT or WARM LRU's (64u) */
155
+ moves_within_lru: bigint
156
+ /** Times worker threads had to directly reclaim or evict items (64u) */
157
+ direct_reclaims: bigint
158
+ /** Number of LRU crawlers running (64u) */
159
+ lru_crawler_running: bigint
160
+ /** Times an LRU crawler was started (64u) */
161
+ lru_crawler_starts: bigint
162
+ /** Number of times the LRU bg thread woke up (64u) */
163
+ lru_maintainer_juggles: bigint
164
+ /** Slab pages returned to global pool for reassignment to other slab classes (32u) */
165
+ slab_global_page_pool: number
166
+ /** Items rescued from eviction in page move (64u) */
167
+ slab_reassign_rescues: bigint
168
+ /** Valid items evicted during a page move (due to no free memory in slab) (64u) */
169
+ slab_reassign_evictions_nomem: bigint
170
+ /** Individual sections of an item rescued during a page move (64u) */
171
+ slab_reassign_chunk_rescues: bigint
172
+ /** Internal stat counter for when the page mover clears memory from the chunk freelist when it wasn't expecting to (64u) */
173
+ slab_reassign_inline_reclaim: bigint
174
+ /** Items busy during page move, requiring a retry before page can be moved (64u) */
175
+ slab_reassign_busy_items: bigint
176
+ /** Items busy during page move, requiring deletion before page can be moved (64u) */
177
+ slab_reassign_busy_deletes: bigint
178
+ /** Logs a worker never wrote due to full buf (64u) */
179
+ log_worker_dropped: bigint
180
+ /** Logs written by a worker, to be picked up (64u) */
181
+ log_worker_written: bigint
182
+ /** Logs not sent to slow watchers (64u) */
183
+ log_watcher_skipped: bigint
184
+ /** Logs written to watchers (64u) */
185
+ log_watcher_sent: bigint
186
+ /** Number of currently active watchers (64u) */
187
+ log_watchers: bigint
188
+ /** Number of times an unexpected napi id is is received. See doc/napi_ids.txt (64u) */
189
+ unexpected_napi_ids: bigint
190
+ /** Number of times napi id of 0 is received resulting in fallback to round robin thread selection. See doc/napi_ids.txt (64u) */
191
+ round_robin_fallback: bigint
192
+ /** Nuumber of times `malloc` failed (64u) */
193
+ malloc_fails: bigint
194
+ }
195
+
196
+ export interface Adapter {
197
+ get(
198
+ key: string,
199
+ options?: { ttl?: number },
200
+ ): Promise<AdapterResult | void>
201
+
202
+ touch(
203
+ key: string,
204
+ options?: { ttl?: number },
205
+ ): Promise<boolean>
206
+
207
+ set(
208
+ key: string,
209
+ value: Buffer,
210
+ options?: { flags?: number, cas?: bigint, ttl?: number },
211
+ ): Promise<bigint | void>
212
+
213
+ add(
214
+ key: string,
215
+ value: Buffer,
216
+ options?: { flags?: number, cas?: bigint, ttl?: number },
217
+ ): Promise<bigint | void>
218
+
219
+ replace(
220
+ key: string,
221
+ value: Buffer,
222
+ options?: { flags?: number, cas?: bigint, ttl?: number },
223
+ ): Promise<bigint | void>
224
+
225
+ append(
226
+ key: string,
227
+ value: Buffer,
228
+ options?: { cas?: bigint },
229
+ ): Promise<boolean>
230
+
231
+ prepend(
232
+ key: string,
233
+ value: Buffer,
234
+ options?: { cas?: bigint },
235
+ ): Promise<boolean>
236
+
237
+ increment(
238
+ key: string,
239
+ delta?: bigint | number,
240
+ options?: { initial?: bigint | number, cas?: bigint, ttl?: number, create?: boolean },
241
+ ): Promise<Counter | void>
242
+
243
+ decrement(
244
+ key: string,
245
+ delta?: bigint | number,
246
+ options?: { initial?: bigint | number, cas?: bigint, ttl?: number, create?: boolean },
247
+ ): Promise<Counter | void>
248
+
249
+ delete(
250
+ key: string,
251
+ options?: { cas?: bigint },
252
+ ): Promise<boolean>
253
+
254
+ flush(ttl?: number): Promise<void>
255
+
256
+ noop(): Promise<void>
257
+
258
+ quit(): Promise<void>
259
+
260
+ version(): Promise<Record<string, string>>
261
+
262
+ stats(): Promise<Record<string, Stats>>
263
+ }