-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
49 lines (35 loc) · 864 Bytes
/
app.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
'use strict'
const records = 100;
var redis = require('redis');
var redisClient = redis.createClient({
host: '192.168.99.100',
port: '6379'
});
processSetCommands(() => {
processGetCommands();
});
function processSetCommands(callback) {
var setCount = 0;
let luaSet = `for i = 0, ${records} do
redis.call("SET", string.format("namespace.key.%d", i), string.format("value.%d", i))
end`;
redisClient.eval(luaSet, 0, function(err, res) {
if (err) {
console.log(`LUA SET Error: ${err}`);
}
callback();
});
}
function processGetCommands() {
let luaGet = `local keys = {}
for i = 0, ${records} do
keys[i+1] = redis.call("GET", string.format("namespace.key.%d", i));
end
return keys`;
redisClient.eval(luaGet, 0, function(err, res) {
if (err) {
console.log(`LUA GET Error: ${err}`);
}
console.log(res);
});
}