Skip to content
Myr

Cache reaper destroys null caches as well

Before adoption: this commit came in with the history the project adopted, so no landing records it.

so they dont linger until expired

authored by visionmedia · committed by visionmedia · parent 7270a13 · Browse files · 2 files+6 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+6 added−4 removed

  • other:+6 added−4 removed

2 files+6 added−4 removed

modified:lib/express/plugins/cache.js+5 added-3 removed
154 unmodified lines
155 var regexp = this.normalize(key),156 keys = Object.keys(this.data)157 for (var i = 0, len = keys.length; i < len; ++i)158 if (regexp.test(keys[i]))159 this.data[keys[i]] = null159 delete this.data[keys[i]]160 }161 callback()162 },163 164 /**165 * Reap caches older than _ms_.165 * Reap caches older than _ms_ or caches which166 * have been "cleared" (null).167 *168 * @param {int} ms169 * @api private170 */
1 unmodified line
172 reap: function(ms) {173 var threshold = +new Date(Date.now() - ms),174 keys = Object.keys(this.data)175 for (var i = 0, len = keys.length; i < len; ++i)175 if (this.data[keys[i]].created < threshold)176 if (this.data[keys[i]].created < threshold ||177 this.data[keys[i]].val === null)178 this.clear(keys[i], function(){})179 },180 181 /**
55 unmodified lines
modified:lib/express/plugins/session.js+1 added-1 removed
126 unmodified lines
127 * @api public128 */129 130 length: function(callback) {131 callback(null, this.store.values.length)131 callback(null, Object.keys(this.store).length)132 },133 134 /**135 * Reap sessions older than _ms_.
98 unmodified lines