| 1 | var Redis = require('../lib/client/Redis.js').Redis;
|
| 2 | // var profiler = require('v8-profiler');
|
| 3 | // profiler.startProfiling('redis');
|
| 4 | // profiler.startProfiling('test');
|
| 5 | // var CredentialsProvider = require('../lib/credentials/CredentialsProvider.js').CredentialsProvider;
|
| 6 | var CredentialsProvider = require('../lib/credentials/CredentialsProvider.js').CredentialsProvider;
|
| 7 | // var cred = new CredentialsProvider('watchlater-ro.redis.skvdb.onetapi.pl', 'watchlater-ro.redis.skvdb.onetapi.pl');
|
| 8 | // profiler.stopProfiling('test');
|
| 9 |
|
| 10 | var cred = new CredentialsProvider({
|
| 11 | db: 9,
|
| 12 | hosts: [{
|
| 13 | host: '10.177.53.43',
|
| 14 | port: 6379
|
| 15 | }, {
|
| 16 | host: '10.162.49.84',
|
| 17 | port: 6379
|
| 18 | },{
|
| 19 | host: '10.177.53.46',
|
| 20 | port: 6379
|
| 21 | }],
|
| 22 | // connections: 20
|
| 23 | });
|
| 24 |
|
| 25 | var redisClient = new Redis(cred);
|
| 26 |
|
| 27 | redisClient.onReady(function () {
|
| 28 | console.log('====> REDIS CLIENT READY <====');
|
| 29 | });
|
| 30 |
|
| 31 | setTimeout(function () {
|
| 32 | console.log('=========update > reduce connections to 2==========');
|
| 33 |
|
| 34 | redisClient.hgetall('7da6f2eb-9212-4cf8-9591-8b940420f65c', function () {
|
| 35 | console.log(arguments);
|
| 36 | });
|
| 37 |
|
| 38 | }, 2000);
|
| 39 |
|
| 40 | //
|
| 41 | // setTimeout(function() {
|
| 42 | // console.log('=========update -> add 127 && 127 && connection 3==========');
|
| 43 | // redisClient._onCredentialsChange(null, {
|
| 44 | // hosts: [{
|
| 45 | // host: 'localhost',
|
| 46 | // port: 6379
|
| 47 | // }, {
|
| 48 | // host: '127.0.0.1',
|
| 49 | // port: 6379
|
| 50 | // }, {
|
| 51 | // host: '127.0.0.1',
|
| 52 | // port: 6379
|
| 53 | // }],
|
| 54 | // connections: 3
|
| 55 | // });
|
| 56 | // // console.log(redisClient.getStats());
|
| 57 | // }, 6000);
|
| 58 | //
|
| 59 | // setTimeout(function() {
|
| 60 | // console.log('=========update -> del 127 ==========');
|
| 61 | // redisClient._onCredentialsChange(null, {
|
| 62 | // hosts: [{
|
| 63 | // host: 'localhost',
|
| 64 | // port: 6379
|
| 65 | // }, {
|
| 66 | // host: '127.0.0.1',
|
| 67 | // port: 6379
|
| 68 | // }],
|
| 69 | // connections: 200
|
| 70 | // });
|
| 71 | //
|
| 72 | // // console.log(redisClient.getStats());
|
| 73 | // }, 8000);
|
| 74 |
|
| 75 | setInterval(function () {
|
| 76 | console.log(redisClient.getStats(), '<<--');
|
| 77 | // console.log(redisClient._pools);
|
| 78 | // redisClient.set('test', new Date().getTime());
|
| 79 | // redisClient.publish('test', new Date().getTime())
|
| 80 | }, 1801);
|