Some comments but it still spams the database with a SET for each request
parent
78d1c5746f
commit
e06da4bf65
|
@ -21,11 +21,11 @@ SessionStore.prototype.get = function(sid, fn){
|
||||||
db.get("sessionstorage:" + sid, function (err, sess)
|
db.get("sessionstorage:" + sid, function (err, sess)
|
||||||
{
|
{
|
||||||
if (sess) {
|
if (sess) {
|
||||||
sess.cookie.expires = 'string' == typeof sess.cookie.expires ? new Date(sess.cookie.expires) : sess.cookie.expires;
|
sess.cookie._expires = 'string' == typeof sess.cookie._expires ? new Date(sess.cookie._expires) : sess.cookie._expires;
|
||||||
if (!sess.cookie.expires || new Date() < sess.cookie.expires) {
|
if (!sess.cookie._expires || new Date() < sess.cookie._expires) {
|
||||||
fn(null, sess);
|
fn(null, sess); // Looks good, proceed :)
|
||||||
} else {
|
} else {
|
||||||
self.destroy(sid, fn);
|
self.destroy(sid, fn); // Destroy sessions that are old
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fn();
|
fn();
|
||||||
|
@ -34,8 +34,10 @@ SessionStore.prototype.get = function(sid, fn){
|
||||||
};
|
};
|
||||||
|
|
||||||
SessionStore.prototype.set = function(sid, sess, fn){
|
SessionStore.prototype.set = function(sid, sess, fn){
|
||||||
|
var currentTS = new Date().getTime(); // Get current timestamp
|
||||||
messageLogger.debug('SET ' + sid);
|
messageLogger.debug('SET ' + sid);
|
||||||
db.set("sessionstorage:" + sid, sess);
|
sess._expires = currentTS + 86400; // Session expires in a day
|
||||||
|
db.set("sessionstorage:" + sid, sess); // Write the session to the database
|
||||||
process.nextTick(function(){
|
process.nextTick(function(){
|
||||||
if(fn) fn();
|
if(fn) fn();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue