# Storing sessions in Redis and other session stores
By default, Apostrophe stores sessions in its MongoDB database. That makes it easier to install Apostrophe. But many developers prefer Redis for sessions. Here's how to configure that.
- Add the
connect-redis
module to your project's npm dependencies:
npm install --save connect-redis
- In
app.js
, configure theapostrophe-express
module to use it:
'apostrophe-express': {
session: {
secret: 'your-secret-here',
store: {
name: 'connect-redis',
options: {
// redis-specific options here. If you don't give any,
// the redis server on localhost is used
}
}
}
}
Notice that you don't have to use require
because Apostrophe does it for you.
This technique is not limited to Redis. You can use any store that follows the standard conventions for connect/Express session store modules.
The options
object you supply is passed on to the store when it is created. For more information about options for Redis, see the connect-redis (opens new window) documentation.
# "What about caches?"
You can also remap Apostrophe's cache mechanism to Redis. Check out the optional apostrophe-caches-redis (opens new window) module.