diff --git a/lib/Lib/Core/Controller.js b/lib/Lib/Core/Controller.js index 8777331a..60560ffe 100644 --- a/lib/Lib/Core/Controller.js +++ b/lib/Lib/Core/Controller.js @@ -182,8 +182,7 @@ module.exports = Class(function() { return instance.rm(); } if (value !== undefined) { - instance.set(name, value); - return this; + return instance.set(name, value); } return instance.get(name); }, diff --git a/lib/Lib/Core/Db.js b/lib/Lib/Core/Db.js index c17e5cdd..b2d79332 100644 --- a/lib/Lib/Core/Db.js +++ b/lib/Lib/Core/Db.js @@ -661,16 +661,17 @@ var Db = module.exports = Class(function(){ cache = options.cache; } var self = this; + var cacheOn = !isEmpty(cache) && C('db_cache_on'); //获取数据 function queryData(){ return self.query(sql).then(function(data){ - if (cache) { + if (cacheOn) { S(key, data, cache); } return data; }); } - if (!isEmpty(cache) && C('db_cache_on')) { + if (cacheOn) { var key = isString(cache.key) && cache.key ? cache.key : md5(sql); return S(key, undefined, cache).then(function(value){ return value || queryData();