lib/mongodb-cache.js
function MongoCache(options) {
    options = options || {};

    var url = options.url || 'http://localhost/openam-agent',
        expireAfterSeconds = options.expireAfterSeconds || 60,
        collectionName = options.collectionName || 'agentcache';

    this.collection = mongodb.MongoClient.connectAsync(url).then(function (db) {
        var collection = db.collection(collectionName);
        return collection.createIndex('timestamp', {expireAfterSeconds: expireAfterSeconds}).then(function () {
            return collection;
        });
    });
}
function MongoCache(options) {
    options = options || {};

    var url = options.url || 'http://localhost/openam-agent',
        expireAfterSeconds = options.expireAfterSeconds || 60,
        collectionName = options.collectionName || 'agentcache';

    this.collection = mongodb.MongoClient.connectAsync(url).then(function (db) {
        var collection = db.collection(collectionName);
        return collection.createIndex('timestamp', {expireAfterSeconds: expireAfterSeconds}).then(function () {
            return collection;
        });
    });
}
function MongoCache ( options ) { options = options || { } ; var url = options . url || 'http://localhost/openam-agent' , expireAfterSeconds = options . expireAfterSeconds || 60 , collectionName = options . collectionName || 'agentcache' ; this . collection = mongodb . MongoClient . connectAsync ( url ) . then ( function ( db ) { var collection = db . collection ( collectionName ) ; return collection . createIndex ( 'timestamp' , { expireAfterSeconds : expireAfterSeconds } ) . then ( function ( ) { return collection ; } ) ; } ) ; }
Cache implementation for MongoDB

@extends Cache

@param {object} [options] Options
@param {string} [options.url=http://localhost/openam-agent] MongoDB URL
@param {number} [options.expireAfterSeconds=60] Expiration time in seconds
@param {string} [options.collectionName=agentcache] MongoDB collection name

@example
var mongoCache = new MongoCache({
url: 'mongodb://db.example.com/mydb',
expireAfterSeconds: 600,
collectionName: 'sessions'
});

@constructor
Cache implementation for MongoDB