A few days ago, I run SailsJs app for the first time in production. This warning showed up.
Warning: connection.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.
I understand that a similar question has been asked and the answer seems to be periodically cleaning up sessionStore with code like.
function sessionCleanup() {
sessionStore.all(function(err, sessions) {
for (var i = 0; i < sessions.length; i++) {
sessionStore.get(sessions[i], function() {} );
}
});
}
How can I get reference to sessionStore in sails.js?
All what you need to do is just replace memory adapter in config/session.js
with another adapter, Redis, for instance.
module.exports.session = {
secret: '<YOUR_SECRET>',
adapter: 'redis',
host: 'localhost',
port: 6379,
ttl: <REDIS_TTL_IN_SECONDS>,
pass: <REDIS_PASSWORD>
prefix: 'sess:'
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With