Authored by 郝肖肖

'按规定存入json字符串'

... ... @@ -25,11 +25,21 @@ const getter = (client, path, memory, cache) => {
let keys = path.replace(/^\/(pc|wap)\//, '').split('/');
memory && _.set(memory, keys, data.toString('utf8') === 'true' ? true : false);
if (keys.indexOf('json') > -1) { // /pc|wap/json/... is JSON string
try {
memory && _.set(memory, keys, JSON.parse(data.toString('utf8')));
} catch (e) {
console.log('%s catch: %s', e.message, path, data.toString('utf8'));
}
} else {
memory && _.set(memory, keys, data.toString('utf8') === 'true' ? true : false);
}
if (cache) {
cache.set('zookeeper:' + path, data.toString('utf8'), ONE_MONTH).catch(console.error);
console.log('cache %s data: %s', 'zookeeper:' + path, data.toString('utf8'));
}
console.log('%s data: %s', path, data.toString('utf8'));
}
)
... ...
{
"name": "yoho-zookeeper",
"version": "1.0.8",
"version": "1.0.9",
"description": "",
"main": "index.js",
"scripts": {
... ...