forked from memcachier/memjs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.js
executable file
·53 lines (44 loc) · 915 Bytes
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#! node --inspect
const MemJS = require(".");
const client = MemJS.Client.create();
let i = 0;
function next(promise) {
const id = i++;
const varname = `r${id}`;
const assign = (r) => {
global[varname] = r;
global["r"] = r;
};
if (promise.then) {
promise.then(
(r) => {
console.log(`r${id} = resolved`, r);
assign(r);
},
(r) => {
console.log(`r${id} = rejected`, r);
assign(r);
}
);
} else {
console.log(`r${id} =`, promise);
assign(promise);
}
}
Object.assign(global, {
MemJS,
client,
next,
p: next,
});
console.log(`
Run as node --inspect cli.js,
then open Chrome inspector up and click the little node icon.
MemJS: memjs library export
client: a client connected to localhost:11211
p: a function to resolve promises
Example:
p(client.get('foo'))
r1.cas.toString()
`);
setInterval(() => {}, 5000);