<commit_before>module.exports = function(raja, session) {
	var Store = session.Store;

	function RajaSessionStore(opts) {
		this.opts = opts || {};
		this.maxage = opts.maxage || 3600 * 24; // defaults to one-day session
		Store.call(this, opts);
	}

	require('util').inherits(RajaSessionStore, Store);

	RajaSessionStore.prototype.get = function(sid, cb) {
		var key = getKey(sid);
		raja.store.get(key, function(err, resource) {
			if (err || !resource) return cb(err);
			if (resource.mtime.getTime() + resource.maxage * 1000 > Date.now()) {
				cb(null, JSON.parse(resource.data.toString()));
			} else {
				raja.store.del(key, cb);
			}
		});
	};

	RajaSessionStore.prototype.set = function(sid, session, cb) {
		var key = getKey(sid);
		raja.store.get(key, function(err, resource) {
			if (err) return cb(err);
			if (!resource) resource = { key: key };

			resource.mtime = new Date();
			resource.maxage = session.cookie.maxAge / 1000 || this.maxage;
			resource.data = JSON.stringify(session);
			raja.store.set(key, resource);
			cb();
		}.bind(this));
	};

	RajaSessionStore.prototype.destroy = function(sid, cb) {
		raja.store.del(getKey(sid), cb);
	};

	function getKey(sid) {
		return 'sid:' + sid;
	}

	return RajaSessionStore;
};<commit_msg>Do not assume session option is set<commit_after>module.exports = function(raja, session) {
	var Store = session.Store;

	function RajaSessionStore(opts) {
		this.opts = opts || {};
		this.maxage = opts.maxage || 3600 * 24; // defaults to one-day session
		Store.call(this, opts);
	}

	require('util').inherits(RajaSessionStore, Store);

	RajaSessionStore.prototype.get = function(sid, cb) {
		var key = getKey(sid);
		raja.store.get(key, function(err, resource) {
			if (err || !resource) return cb(err);
			if (resource.mtime.getTime() + resource.maxage * 1000 > Date.now()) {
				cb(null, JSON.parse(resource.data.toString()));
			} else {
				raja.store.del(key, cb);
			}
		});
	};

	RajaSessionStore.prototype.set = function(sid, session, cb) {
		var key = getKey(sid);
		raja.store.get(key, function(err, resource) {
			if (err) return cb(err);
			if (!resource) resource = { key: key };

			resource.mtime = new Date();
			resource.maxage = session.cookie && session.cookie.maxAge / 1000 || this.maxage;
			resource.data = JSON.stringify(session);
			raja.store.set(key, resource);
			cb();
		}.bind(this));
	};

	RajaSessionStore.prototype.destroy = function(sid, cb) {
		raja.store.del(getKey(sid), cb);
	};

	function getKey(sid) {
		return 'sid:' + sid;
	}

	return RajaSessionStore;
};
{'fraction_non_alphanumeric': 0.16705790297339593, 'fraction_numerical': 0.010954616588419406, 'mean_word_length': 3.806390977443609, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7517011', 'n_tokens_mistral': 1011, 'n_tokens_neox': 890, 'n_words': 187}