@stinkycomputing/cachearoo 1.0.24
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/.github/workflows/build_and_test.yml +29 -0
- package/.github/workflows/npm-publish.yml +30 -0
- package/README.md +400 -0
- package/dist/cachearoo-node.d.ts +19 -0
- package/dist/cachearoo-node.js +31 -0
- package/dist/cachearoo.d.ts +19 -0
- package/dist/cachearoo.es.js +2996 -0
- package/dist/cachearoo.min.js +15 -0
- package/dist/libs/cro.connection.d.ts +71 -0
- package/dist/libs/cro.connection.js +401 -0
- package/dist/libs/cro.d.ts +82 -0
- package/dist/libs/cro.js +283 -0
- package/dist/libs/cro.msg.competing-consumers.d.ts +46 -0
- package/dist/libs/cro.msg.competing-consumers.js +204 -0
- package/dist/libs/cro.msg.request-reply.d.ts +32 -0
- package/dist/libs/cro.msg.request-reply.js +117 -0
- package/package.json +36 -0
- package/tsconfig-node.json +32 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PersistentConnection = void 0;
|
|
4
|
+
const util_1 = require("util");
|
|
5
|
+
const websocket_1 = require("websocket");
|
|
6
|
+
const cro_1 = require("./cro");
|
|
7
|
+
const REQUEST_TIMEOUT = 3000;
|
|
8
|
+
function headerToBuffer(header) {
|
|
9
|
+
const buf = new Uint8Array(128);
|
|
10
|
+
let offset = 0;
|
|
11
|
+
const Encoder = (typeof window !== 'undefined') ? window.TextEncoder : util_1.TextEncoder;
|
|
12
|
+
const encoder = new Encoder();
|
|
13
|
+
const bucket = encoder.encode(header.bucket);
|
|
14
|
+
const key = encoder.encode(header.key);
|
|
15
|
+
const apiKey = encoder.encode(header.apiKey);
|
|
16
|
+
if ((bucket.byteLength > 36) || (key.byteLength > 36) || (apiKey.byteLength > 36)) {
|
|
17
|
+
throw new Error('Cannot write binary header, bucket/key/apiKey cannot exceed 36 bytes each');
|
|
18
|
+
}
|
|
19
|
+
buf[0] = header.type;
|
|
20
|
+
buf[1] = bucket.byteLength;
|
|
21
|
+
buf[2] = key.byteLength;
|
|
22
|
+
buf[3] = apiKey.byteLength;
|
|
23
|
+
offset = 4;
|
|
24
|
+
buf.set(bucket, offset);
|
|
25
|
+
offset += buf[1];
|
|
26
|
+
buf.set(key, offset);
|
|
27
|
+
offset += buf[2];
|
|
28
|
+
buf.set(apiKey, offset);
|
|
29
|
+
return buf;
|
|
30
|
+
}
|
|
31
|
+
function bufferToHeader(buffer) {
|
|
32
|
+
let bucketSize = buffer[1];
|
|
33
|
+
let keySize = buffer[2];
|
|
34
|
+
let apiKeySize = buffer[3];
|
|
35
|
+
const Decoder = (typeof window !== 'undefined') ? window.TextDecoder : util_1.TextDecoder;
|
|
36
|
+
const decoder = new Decoder('utf-8');
|
|
37
|
+
const res = {
|
|
38
|
+
type: buffer[0],
|
|
39
|
+
bucket: '',
|
|
40
|
+
key: '',
|
|
41
|
+
apiKey: '',
|
|
42
|
+
};
|
|
43
|
+
let offset = 4;
|
|
44
|
+
res.bucket = decoder.decode(buffer.slice(offset, offset + bucketSize));
|
|
45
|
+
offset = offset + bucketSize;
|
|
46
|
+
res.key = decoder.decode(buffer.slice(offset, offset + keySize));
|
|
47
|
+
offset = offset + keySize;
|
|
48
|
+
res.apiKey = decoder.decode(buffer.slice(offset, offset + apiKeySize));
|
|
49
|
+
return res;
|
|
50
|
+
}
|
|
51
|
+
class PersistentConnection {
|
|
52
|
+
onConnect;
|
|
53
|
+
onDisconnect;
|
|
54
|
+
onError;
|
|
55
|
+
onPong;
|
|
56
|
+
connected = false;
|
|
57
|
+
id = undefined;
|
|
58
|
+
enablePing = false;
|
|
59
|
+
settings;
|
|
60
|
+
requestID = 0;
|
|
61
|
+
events = [];
|
|
62
|
+
binaryEvents = [];
|
|
63
|
+
sendValues = false;
|
|
64
|
+
ws = undefined;
|
|
65
|
+
eventsReceived = 0;
|
|
66
|
+
skipReconnect = false;
|
|
67
|
+
requests = [];
|
|
68
|
+
requestTimer = undefined;
|
|
69
|
+
reconnectTimer = undefined;
|
|
70
|
+
pingTimer = undefined;
|
|
71
|
+
pingInterval = 5000;
|
|
72
|
+
apiKey;
|
|
73
|
+
async request(options) {
|
|
74
|
+
if (!options.key)
|
|
75
|
+
options.key = '';
|
|
76
|
+
const bucket = options.bucket || this.settings.bucket || '';
|
|
77
|
+
const method = options.method || 'GET';
|
|
78
|
+
if ((method === 'GET') && (options.key === '')) {
|
|
79
|
+
return this.list(bucket, options.keysOnly, options.filter);
|
|
80
|
+
}
|
|
81
|
+
else if (method === 'GET') {
|
|
82
|
+
return this.read(bucket, options.key);
|
|
83
|
+
}
|
|
84
|
+
else if ((method === 'POST') || (method === 'PUT')) {
|
|
85
|
+
return this.write(bucket, options.key, options.data, options.failIfExists, options.expire);
|
|
86
|
+
}
|
|
87
|
+
else if (method === 'DELETE') {
|
|
88
|
+
return this.delete(bucket, options.key);
|
|
89
|
+
}
|
|
90
|
+
else if (method === 'PATCH') {
|
|
91
|
+
return this.patch(bucket, options.key, options.data, options.removeDataFromReply);
|
|
92
|
+
}
|
|
93
|
+
else if (method === 'EVENT') {
|
|
94
|
+
return this.signalEvent(bucket, options.key, options.data);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
;
|
|
98
|
+
constructor(settings) {
|
|
99
|
+
this.settings = settings;
|
|
100
|
+
this.enablePing = !!settings.enablePing;
|
|
101
|
+
this.pingInterval = settings.pingInterval || this.pingInterval;
|
|
102
|
+
var protocol = (settings.secure) ? 'wss://' : 'ws://';
|
|
103
|
+
this.apiKey = settings.apiKey;
|
|
104
|
+
const subDomain = settings.wsSubDomain ? settings.wsSubDomain + '.' : '';
|
|
105
|
+
const url = protocol + subDomain + settings.host + ':' + settings.port + settings.path + '?id=' + settings.clientId + "&apiKey=" + (settings.apiKey || '');
|
|
106
|
+
this.wsStart(url);
|
|
107
|
+
this.checkRequestTimeouts();
|
|
108
|
+
}
|
|
109
|
+
async read(bucket, key) {
|
|
110
|
+
return new Promise((resolve, reject) => {
|
|
111
|
+
this.addRequest({ op: 'read', bucket: bucket, key: key }, function (err, obj) {
|
|
112
|
+
if (err) {
|
|
113
|
+
reject(new Error('Cachearoo ws READ error: ' + JSON.stringify(err) + ' for bucket: ' + bucket + ', key: ' + key));
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
resolve(obj);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
;
|
|
122
|
+
async list(bucket, keysOnly, filter) {
|
|
123
|
+
return new Promise((resolve, reject) => {
|
|
124
|
+
this.addRequest({ op: 'filter', bucket: bucket, keysOnly: keysOnly, filter: filter }, function (err, location) {
|
|
125
|
+
if (err) {
|
|
126
|
+
reject(new Error('Cachearoo ws FILTER error: ' + JSON.stringify(err) + ' for bucket: ' + bucket));
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
resolve(location);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
async write(bucket, key, value, failIfExists, expire) {
|
|
135
|
+
return new Promise((resolve, reject) => {
|
|
136
|
+
this.addRequest({ op: 'write', bucket: bucket, key: key, value: value, failIfExists: failIfExists, expire: expire }, function (err, location) {
|
|
137
|
+
if (err) {
|
|
138
|
+
const error = ((err.alreadyExists) ? new cro_1.AlreadyExistsError(`Key ${key} already exists`) :
|
|
139
|
+
new Error('Cachearoo ws WRITE error: ' + JSON.stringify(err) + ' for bucket: ' + bucket + ', key: ' + key));
|
|
140
|
+
reject(error);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
resolve(location);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
;
|
|
149
|
+
async patch(bucket, key, patch, removeDataFromReply) {
|
|
150
|
+
return new Promise((resolve, reject) => {
|
|
151
|
+
this.addRequest({ op: 'patch', bucket, key, patch, removeDataFromReply }, function (err, result) {
|
|
152
|
+
if (err) {
|
|
153
|
+
reject(new Error('Cachearoo ws PATCH error: ' + JSON.stringify(err) + ' for bucket: ' + bucket + ', key: ' + key));
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
resolve(result);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
;
|
|
162
|
+
async delete(bucket, key) {
|
|
163
|
+
return new Promise((resolve, reject) => {
|
|
164
|
+
this.addRequest({ op: 'remove', bucket: bucket, key: key }, function (err) {
|
|
165
|
+
if (err) {
|
|
166
|
+
reject(new Error('Cachearoo ws REMOVE error: ' + JSON.stringify(err) + ' for bucket: ' + bucket + ', key: ' + key));
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
resolve();
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
;
|
|
175
|
+
async signalEvent(bucket, key, value) {
|
|
176
|
+
var eventObj = { bucket: bucket, key: key, value: value };
|
|
177
|
+
if ((this.connected) && (this.ws)) {
|
|
178
|
+
this.ws.send(JSON.stringify({ msg: 'event-broadcast', apiKey: this.apiKey, event: eventObj }));
|
|
179
|
+
return Promise.resolve();
|
|
180
|
+
}
|
|
181
|
+
return Promise.reject(new Error('Cannot call SignalEvent when disconnected'));
|
|
182
|
+
}
|
|
183
|
+
;
|
|
184
|
+
async signalEventBinary(type, bucket, key, value) {
|
|
185
|
+
const header = {
|
|
186
|
+
type,
|
|
187
|
+
bucket,
|
|
188
|
+
key,
|
|
189
|
+
apiKey: this.apiKey || '',
|
|
190
|
+
};
|
|
191
|
+
const data = headerToBuffer(header);
|
|
192
|
+
if ((this.connected) && (this.ws)) {
|
|
193
|
+
this.ws.send(Buffer.concat([data, value]));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
close() {
|
|
197
|
+
this.events = [];
|
|
198
|
+
this.skipReconnect = true;
|
|
199
|
+
this.connected = false;
|
|
200
|
+
if ((this.ws) && (this.ws.close)) {
|
|
201
|
+
this.ws.close();
|
|
202
|
+
}
|
|
203
|
+
this.ws = undefined;
|
|
204
|
+
clearTimeout(this.reconnectTimer);
|
|
205
|
+
clearInterval(this.pingTimer);
|
|
206
|
+
clearTimeout(this.requestTimer);
|
|
207
|
+
}
|
|
208
|
+
;
|
|
209
|
+
addListenerBinary(bucket, key, callback) {
|
|
210
|
+
if ((callback == null) || (typeof callback != 'function'))
|
|
211
|
+
throw 'Callback is not a function';
|
|
212
|
+
this.binaryEvents.push({
|
|
213
|
+
bucket: bucket,
|
|
214
|
+
key: key,
|
|
215
|
+
callback: callback
|
|
216
|
+
});
|
|
217
|
+
this.registerEvents();
|
|
218
|
+
}
|
|
219
|
+
;
|
|
220
|
+
addListener(bucket, key, sendValues, callback) {
|
|
221
|
+
if ((callback == null) || (typeof callback != 'function'))
|
|
222
|
+
throw 'Callback is not a function';
|
|
223
|
+
if (sendValues)
|
|
224
|
+
this.sendValues = true;
|
|
225
|
+
this.events.push({
|
|
226
|
+
bucket: bucket,
|
|
227
|
+
key: key,
|
|
228
|
+
callback: callback
|
|
229
|
+
});
|
|
230
|
+
this.registerEvents();
|
|
231
|
+
}
|
|
232
|
+
;
|
|
233
|
+
removeListener(callback) {
|
|
234
|
+
this.events = this.events.filter(item => item.callback !== callback);
|
|
235
|
+
this.binaryEvents = this.binaryEvents.filter(item => item.callback !== callback);
|
|
236
|
+
this.registerEvents();
|
|
237
|
+
}
|
|
238
|
+
removeAllListeners() {
|
|
239
|
+
this.events = [];
|
|
240
|
+
this.binaryEvents = [];
|
|
241
|
+
}
|
|
242
|
+
addRequest(obj, callback) {
|
|
243
|
+
this.requestID = this.requestID + 1;
|
|
244
|
+
this.requests[this.requestID] = { timeStamp: new Date(), callback: callback };
|
|
245
|
+
obj.id = this.requestID + '';
|
|
246
|
+
if ((this.connected) && (this.ws)) {
|
|
247
|
+
this.ws.send(JSON.stringify({ msg: 'datastore-operation', apiKey: this.apiKey, request: obj }));
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
;
|
|
251
|
+
handleReponse(response) {
|
|
252
|
+
if (this.requests[response.id]) {
|
|
253
|
+
this.requests[response.id].callback(response.error, response.value || response.location);
|
|
254
|
+
this.requests[response.id] = null;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
;
|
|
258
|
+
checkRequestTimeouts() {
|
|
259
|
+
this.requestTimer = setTimeout(() => {
|
|
260
|
+
for (var i in this.requests) {
|
|
261
|
+
var req = this.requests[i + ''];
|
|
262
|
+
if (req) {
|
|
263
|
+
var now = new Date().getTime();
|
|
264
|
+
if (now - this.requests[i].timeStamp > REQUEST_TIMEOUT) {
|
|
265
|
+
req.callback('Timeout occured for request ' + req.id);
|
|
266
|
+
this.requests[i] = null;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (!this.skipReconnect)
|
|
271
|
+
this.checkRequestTimeouts();
|
|
272
|
+
}, 1000);
|
|
273
|
+
}
|
|
274
|
+
;
|
|
275
|
+
registerEvents() {
|
|
276
|
+
if (this.connected) {
|
|
277
|
+
var eventMap = [];
|
|
278
|
+
var eventArr = [];
|
|
279
|
+
const events = [...this.events, ...this.binaryEvents];
|
|
280
|
+
for (var i = 0; i < events.length; i++) {
|
|
281
|
+
var eventJson = JSON.stringify(events[i]);
|
|
282
|
+
if (!eventMap[eventJson]) {
|
|
283
|
+
eventArr.push({
|
|
284
|
+
bucket: events[i].bucket,
|
|
285
|
+
key: events[i].key
|
|
286
|
+
});
|
|
287
|
+
eventMap[eventJson] = true;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
this.ws?.send(JSON.stringify({
|
|
291
|
+
msg: 'register-events',
|
|
292
|
+
events: eventArr,
|
|
293
|
+
sendValues: this.sendValues,
|
|
294
|
+
apiKey: this.apiKey
|
|
295
|
+
}));
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
;
|
|
299
|
+
processBinaryMessage(data) {
|
|
300
|
+
if (data.byteLength < 128)
|
|
301
|
+
return console.error('Binary data without header');
|
|
302
|
+
const header = bufferToHeader(new Uint8Array(data));
|
|
303
|
+
for (var i = 0; i < this.binaryEvents.length; i++) {
|
|
304
|
+
if (((this.binaryEvents[i].bucket === '*') || (this.binaryEvents[i].bucket == header.bucket)) &&
|
|
305
|
+
((this.binaryEvents[i].key === '*') || (this.binaryEvents[i].key == header.key))) {
|
|
306
|
+
this.binaryEvents[i].callback({
|
|
307
|
+
type: header.type,
|
|
308
|
+
bucket: header.bucket,
|
|
309
|
+
key: header.key,
|
|
310
|
+
content: data.slice(128),
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
processStringMessage(message) {
|
|
316
|
+
var eventObj = JSON.parse(message);
|
|
317
|
+
if (eventObj.id) {
|
|
318
|
+
this.id = eventObj.id;
|
|
319
|
+
if (typeof this.onConnect === 'function') {
|
|
320
|
+
this.onConnect(this);
|
|
321
|
+
}
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
if (eventObj.response) {
|
|
325
|
+
this.handleReponse(eventObj.response);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
if (eventObj.pong) {
|
|
329
|
+
if (typeof this.onPong === 'function') {
|
|
330
|
+
this.onPong();
|
|
331
|
+
}
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
this.eventsReceived++;
|
|
335
|
+
var value = ((typeof eventObj.value !== 'undefined') && (typeof eventObj.isDeleted === 'undefined')) ? eventObj.value : null;
|
|
336
|
+
var obj = {
|
|
337
|
+
bucket: eventObj.bucket,
|
|
338
|
+
key: eventObj.key,
|
|
339
|
+
value: value,
|
|
340
|
+
isDeleted: undefined
|
|
341
|
+
};
|
|
342
|
+
if (eventObj.isDeleted)
|
|
343
|
+
obj.isDeleted = true;
|
|
344
|
+
for (var i = 0; i < this.events.length; i++) {
|
|
345
|
+
if (((this.events[i].bucket === '*') || (this.events[i].bucket == obj.bucket)) &&
|
|
346
|
+
((this.events[i].key === '*') || (this.events[i].key == obj.key))) {
|
|
347
|
+
this.events[i].callback(obj);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
wsStart(url) {
|
|
352
|
+
this.skipReconnect = false;
|
|
353
|
+
this.connected = false;
|
|
354
|
+
if (this.pingTimer)
|
|
355
|
+
clearInterval(this.pingTimer);
|
|
356
|
+
if ((this.ws) && (this.ws.close))
|
|
357
|
+
this.ws.close();
|
|
358
|
+
this.ws = new websocket_1.w3cwebsocket(url, '', undefined, undefined, undefined, { maxReceivedMessageSize: 128 * 1024 * 1024 });
|
|
359
|
+
this.ws.binaryType = 'arraybuffer';
|
|
360
|
+
if (this.enablePing) {
|
|
361
|
+
this.pingTimer = setInterval(() => {
|
|
362
|
+
if ((this.ws != null) && (this.connected)) {
|
|
363
|
+
this.ws.send(JSON.stringify({ msg: 'ping' }));
|
|
364
|
+
}
|
|
365
|
+
}, this.pingInterval);
|
|
366
|
+
}
|
|
367
|
+
this.ws.onerror = (error) => {
|
|
368
|
+
if (typeof this.onError === 'function')
|
|
369
|
+
this.onError(error);
|
|
370
|
+
};
|
|
371
|
+
this.ws.onmessage = (message) => {
|
|
372
|
+
if (typeof message.data === 'string') {
|
|
373
|
+
this.processStringMessage(message.data);
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
this.processBinaryMessage(message.data);
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
this.ws.onclose = () => {
|
|
380
|
+
if (this.connected) {
|
|
381
|
+
this.connected = false;
|
|
382
|
+
if (typeof this.onDisconnect === 'function') {
|
|
383
|
+
this.onDisconnect(this);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
if (!this.skipReconnect) {
|
|
387
|
+
this.reconnectTimer = setTimeout(() => {
|
|
388
|
+
if (!this.skipReconnect) {
|
|
389
|
+
this.wsStart(url);
|
|
390
|
+
}
|
|
391
|
+
}, 3000);
|
|
392
|
+
}
|
|
393
|
+
;
|
|
394
|
+
};
|
|
395
|
+
this.ws.onopen = () => {
|
|
396
|
+
this.connected = true;
|
|
397
|
+
this.registerEvents();
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
exports.PersistentConnection = PersistentConnection;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { PersistentConnection } from './cro.connection';
|
|
2
|
+
export declare class TimeoutError extends Error {
|
|
3
|
+
progressTimeout: boolean;
|
|
4
|
+
constructor(message: any, progressTimeout: any);
|
|
5
|
+
}
|
|
6
|
+
export declare class AlreadyExistsError extends Error {
|
|
7
|
+
constructor(message: any);
|
|
8
|
+
}
|
|
9
|
+
export declare function generateUUID(): string;
|
|
10
|
+
export interface ICachearooSettings {
|
|
11
|
+
bucket?: string;
|
|
12
|
+
host?: string;
|
|
13
|
+
port?: number;
|
|
14
|
+
path?: string;
|
|
15
|
+
apiKey?: string;
|
|
16
|
+
secure?: boolean;
|
|
17
|
+
enablePing?: boolean;
|
|
18
|
+
pingInterval?: number;
|
|
19
|
+
clientId?: string;
|
|
20
|
+
wsSubDomain?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare class CachearooSettings {
|
|
23
|
+
bucket?: string;
|
|
24
|
+
host?: string;
|
|
25
|
+
port?: number;
|
|
26
|
+
path: string;
|
|
27
|
+
apiKey?: string;
|
|
28
|
+
secure: boolean;
|
|
29
|
+
enablePing: boolean;
|
|
30
|
+
pingInterval: number;
|
|
31
|
+
clientId?: string;
|
|
32
|
+
wsSubDomain?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare class RequestOptions {
|
|
35
|
+
bucket?: string;
|
|
36
|
+
data?: string;
|
|
37
|
+
failIfExists: boolean;
|
|
38
|
+
expire?: string;
|
|
39
|
+
async: boolean;
|
|
40
|
+
forceHttp: boolean;
|
|
41
|
+
keysOnly: boolean;
|
|
42
|
+
filter?: string;
|
|
43
|
+
removeDataFromReply: boolean;
|
|
44
|
+
constructor(options: any);
|
|
45
|
+
}
|
|
46
|
+
export declare class RequestOptionsInternal extends RequestOptions {
|
|
47
|
+
url?: string;
|
|
48
|
+
method?: string;
|
|
49
|
+
key?: string;
|
|
50
|
+
forceHttp: boolean;
|
|
51
|
+
keysOnly: boolean;
|
|
52
|
+
filter?: string;
|
|
53
|
+
removeDataFromReply: boolean;
|
|
54
|
+
isList: boolean;
|
|
55
|
+
}
|
|
56
|
+
export interface IListReplyItem {
|
|
57
|
+
key: string;
|
|
58
|
+
timestamp: string;
|
|
59
|
+
size: number;
|
|
60
|
+
expire?: Date;
|
|
61
|
+
content?: object;
|
|
62
|
+
}
|
|
63
|
+
export declare class Cachearoo {
|
|
64
|
+
connection: PersistentConnection;
|
|
65
|
+
private settings;
|
|
66
|
+
private requestQueue;
|
|
67
|
+
private pendingRequests;
|
|
68
|
+
private internalizeRequestOptions;
|
|
69
|
+
private checkOptions;
|
|
70
|
+
read(key: string, options?: RequestOptions): Promise<unknown>;
|
|
71
|
+
list(options?: RequestOptions): Promise<IListReplyItem[]>;
|
|
72
|
+
write(key: string, value: any, options?: RequestOptions): Promise<unknown>;
|
|
73
|
+
patch(key: string, patch: string, options?: RequestOptions): Promise<unknown>;
|
|
74
|
+
remove(key: string, options?: RequestOptions): Promise<unknown>;
|
|
75
|
+
repair(bucket: string): Promise<any>;
|
|
76
|
+
private getUrl;
|
|
77
|
+
private requestHttp;
|
|
78
|
+
private request;
|
|
79
|
+
private processRequestQueue;
|
|
80
|
+
close(): void;
|
|
81
|
+
constructor(settings?: ICachearooSettings);
|
|
82
|
+
}
|