From b92180d28c88b909cb3c97af94b0dba76e044ba6 Mon Sep 17 00:00:00 2001 From: Jdaie <490844515@qq.com> Date: Fri, 13 Sep 2019 00:08:43 +0800 Subject: [PATCH 1/2] Update index.js bug fix --- lib/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/index.js b/lib/index.js index 15e9274..f60406d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -29,19 +29,19 @@ var cache = { if (this.dataExpire[key]*1000+ this.dataTime[key] < new Date().getTime()/1000) { this.data[key] = null; - callback(null); + callback(null, null); } else { - callback(this.data[key]); + callback(null, this.data[key]); } }, set: function(key, val, callback){ this.data[key] = val; this.dataTime[key] = new Date().getTime(); - if (callback) callback(val); + if (callback) callback(null, val); }, expire: function(key, val, callback){ this.dataExpire[key] = val; - if (callback) callback(val); + if (callback) callback(null, val); } }; From 8d3f338315f7f8e894e807113ad2fe4de5b7c11a Mon Sep 17 00:00:00 2001 From: Jdaie <490844515@qq.com> Date: Fri, 13 Sep 2019 09:28:47 +0800 Subject: [PATCH 2/2] bug fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 毫秒比较不需要除1000 --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index f60406d..d39176b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -27,7 +27,7 @@ var cache = { if (!callback) return; if (!this.dataExpire[key]) return callback(this.data[key]); - if (this.dataExpire[key]*1000+ this.dataTime[key] < new Date().getTime()/1000) { + if (this.dataExpire[key]*1000+ this.dataTime[key] < new Date().getTime()) { this.data[key] = null; callback(null, null); } else {