-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
59 lines (47 loc) · 1.26 KB
/
test.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
54
55
56
57
58
'use strict';
const Redis = require('ioredis');
const redisPool = require('./index');
// var client = redisPool.createClient();
// client.on('ready', () => {
// console.log('ready1');
// });
function clientFactory() {
return new Redis({
sentinels: [{
host: 'localhost',
port: 26379
}],
name: 'mymaster'
});
}
const poolOptions = {
poolKey: 'my-pool',
clientFactory: clientFactory,
redisOptions: {
port: 6379,
options: {}
},
poolOptions: {
min: 1,
max: 2
}
}
const clientOptions = {
poolKey: 'my-pool'
}
async function start() {
redisPool.createPool(poolOptions);
var client1 = await redisPool.createClient(clientOptions);
var client2 = await redisPool.createClient(clientOptions);
setTimeout(() => {
redisPool.releaseClient(client1, clientOptions);
}, 2000);
setTimeout(() => {
redisPool.releaseClient(client2, clientOptions);
}, 3000);
// var client3 = await redisPool.createClient(clientOptions);
// var client4 = await redisPool.createClient(clientOptions);
// var client5 = await redisPool.createClient(clientOptions);
// var client6 = await redisPool.createClient(clientOptions);
};
start();