Skip to content

Commit

Permalink
Include expirationTimestamp field separated from data
Browse files Browse the repository at this point in the history
Allows simple queries to clean up DataStore with expired sessions
  • Loading branch information
sceee committed Sep 22, 2018
1 parent 3390d81 commit 1a4249e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@ module.exports = function (session) {
return callback(err);
}

const sessExprTimestamp = (sess.cookie && sess.cookie.expires) ? sess.cookie.expires.getTime() : '';

this.ds.save({
key: this.ds.key(['Session', sid]),
data: [{
name: 'data',
value: sessJson,
excludeFromIndexes: true
}, {
name: 'expirationTimestamp',
value: sessExprTimestamp
}]
}, callback);
};
Expand Down

0 comments on commit 1a4249e

Please sign in to comment.