From bc824e6e0223f82638bcbd1a82b39327d57a56c7 Mon Sep 17 00:00:00 2001 From: dan <464033315@qq.com> Date: Tue, 14 Jul 2015 14:04:16 +0800 Subject: [PATCH] =?UTF-8?q?memoryStore.set()=20=E5=A2=9E=E5=8A=A0=20maxAge?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/stores/memory.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/stores/memory.js b/lib/stores/memory.js index cece561..ad548a4 100644 --- a/lib/stores/memory.js +++ b/lib/stores/memory.js @@ -18,8 +18,13 @@ var memoryStore = function(args) { self.set = function(key, value, options, cb) { if (typeof options === 'function') { cb = options; + options = {}; } - lruCache.set(key, value); + options = options || {}; + + var maxAge = (options.ttl || options.ttl === 0) ? options.ttl : lruOpts.maxAge; + + lruCache.set(key, value, maxAge); if (cb) { process.nextTick(cb); }