Skip to content
Myr

Fixed session / cache key iteration due to ext changes

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

authored by visionmedia · committed by visionmedia · parent defb159 · Browse files · 2 files+17 added−21 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+17 added−21 removed

  • other:+17 added−21 removed

2 files+17 added−21 removed

modified:lib/express/plugins/cache.js+11 added-13 removed
149 unmodified lines
150 clear: function(key, callback) {151 if (key.indexOf('*') === -1)152 delete this.data[key]153 else {154 var regexp = this.normalize(key)155 this.data.each(function(val, key){156 if (regexp.test(key))157 delete this.data[key]158 }, this)154 var regexp = this.normalize(key),155 keys = Object.keys(this.data)156 for (var i = 0, len = keys.length; i < len; ++i)157 if (regexp.test(this.data[keys[i]]))158 delete this.data[keys[i]]159 }160 callback()161 },162
3 unmodified lines
166 * @param {int} ms167 * @api private168 */169 170 reap: function(ms, callback) {171 var self = this,172 threshold = +new Date(Date.now() - ms)173 this.data.each(function(cache){174 if (cache.created < threshold)175 self.clear(cache.key, function(){})176 })177 if (callback) callback()170 reap: function(ms) {171 var threshold = +new Date(Date.now() - ms),172 keys = Object.keys(this.data)173 for (var i = 0, len = keys.length; i < len; ++i)174 if (this.data[keys[i]].created < threshold)175 this.clear(keys[i], function(){})176 },177 178 /**179 * Convert the given key matching _pattern_
52 unmodified lines
modified:lib/express/plugins/session.js+6 added-8 removed
133 unmodified lines
134 /**135 * Reap sessions older than _ms_.136 *137 * @param {int} ms138 * @param {function} callback138 * @api private139 */140 142 reap: function(ms, callback) {143 var threshold = +new Date(Date.now() - ms)144 this.store.each(function(session, sid){145 if (session.lastAccess < threshold)146 this.destroy(sid)147 }, this)148 if (callback) callback()141 reap: function(ms) {142 var threshold = +new Date(Date.now() - ms),143 sids = Object.keys(this.store)144 for (var i = 0, len = sids.length; i < len; ++i)145 if (this.store[sids[i]].lastAccess < threshold)146 this.destroy(sids[i])147 },148149 /**150 * Creates and passes a shiny new session.
83 unmodified lines