Using Apigee Cache as the session store for Expressjs applications

4 3 868

Node applications developed using Expressjs and deployed on Apigee Cloud can now use the Apigee Cache as its session store, with the help of this new Express-Session-Apigee-Cache node module.

Github Url: express-session-apigee-cache

Overview:

We see a lot of developers building server side nodejs applications using Expressjs and Apigee Edge. One of the common challenges they face while building engaging user experience is to manage state efficiently given the distributed nature of Apigee runtime. This module helps alleviate this problem by leveraging Apigee's highly scalable multi layer caching mechanism (to persist sessions) and thereby provide consistent user experience, irrespective of the Message Processor (MP), the request is served from.

Comments
ozanseymen
Staff

Can you elaborate on the differences between this and volos cache module please? Why should we use this instead of volos cache?

Not applicable

Hi @oseymen@apigee.com,

This module acts as a facilitator for the express-session module to use apigee-cache as the session store. This module is not a replacement for volos-cache.

This module can be used when you are building a node web app using expressjs which eventually will be deployed on Apigee Cloud, and you want to store the state information across multiple page requests.

To maintain such state information you might need to use the express-session module that will handle most of the session related functionality for the app, and it requires a storage for the session data.

If the session data is stored at the application level, it may get lost due to the distributed nature of Apigee runtime. In order to allow the application to store the session data in the apigee cache, the expess-session-apigee-cache module acts a store plugin for express-session module that simplifies the process so that the application need not worry about storing and retrieving from the cache.

The application just needs to initialize the session with apigee-store as below.

var session = require('express-session');
var ApigeeStore = require('express-session-apigee-cache')(session);
var options = {
  cache: <name of the cache to use>,
  prefix: "<prefix>",
  ttl: 300,
}
app.use(session({
   store: new ApigeeStore(options),
   secret: 'keyboard cat',
}));

And the expess-session-apigee-cache module takes care of storing, retrieving and deleting the data from the Apigee cache

Cheers,

Sudheesh

Not applicable

Pretty cool! I hadn't seen this post. Thanks @sdamodaran!

Version history
Last update:
‎01-04-2016 11:18 PM
Updated by: