Authored by 姜枫

fix memcacahed timeout

@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 const zookeeper = require('node-zookeeper-client'); 9 const zookeeper = require('node-zookeeper-client');
10 const _ = require('lodash'); 10 const _ = require('lodash');
11 11
12 -const ONE_YEAR = 60 * 60 * 24 * 365; 12 +const ONE_MONTH = 60 * 60 * 24 * 30;
13 13
14 const getter = (client, path, memory, cache) => { 14 const getter = (client, path, memory, cache) => {
15 client.getData( 15 client.getData(
@@ -27,11 +27,8 @@ const getter = (client, path, memory, cache) => { @@ -27,11 +27,8 @@ const getter = (client, path, memory, cache) => {
27 27
28 memory && _.set(memory, keys, data.toString('utf8') === 'true' ? true : false); 28 memory && _.set(memory, keys, data.toString('utf8') === 'true' ? true : false);
29 if (cache) { 29 if (cache) {
30 - try {  
31 - cache.set('zookeeper:' + path, data.toString('utf8'), ONE_YEAR);  
32 - console.log('cache %s data: %s', 'zookeeper:' + path, data.toString('utf8'));  
33 - } catch (e) {  
34 - } 30 + cache.set('zookeeper:' + path, data.toString('utf8'), ONE_MONTH).catch(console.error);
  31 + console.log('cache %s data: %s', 'zookeeper:' + path, data.toString('utf8'));
35 } 32 }
36 console.log('%s data: %s', path, data.toString('utf8')); 33 console.log('%s data: %s', path, data.toString('utf8'));
37 } 34 }
1 { 1 {
2 "name": "yoho-zookeeper", 2 "name": "yoho-zookeeper",
3 - "version": "1.0.7", 3 + "version": "1.0.8",
4 "description": "", 4 "description": "",
5 "main": "index.js", 5 "main": "index.js",
6 "scripts": { 6 "scripts": {