This commit is contained in:
welefen 2014-04-23 19:38:26 +08:00
parent b3d9d37209
commit de416e5f33
2 changed files with 4 additions and 4 deletions

View File

@ -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);
},

View File

@ -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();