Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sessionstore

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sessionstore - npm Package Compare versions

Comparing version 0.3.0 to 0.4.1

lib/databases/memcached.js

10

lib/databases/mongodb.js

@@ -124,8 +124,10 @@ var util = require(process.binding('natives').util ? 'util' : 'sys'),

var arr = [];
this.sessions.find(function(err, cursor) {
cursor.each(function(d) {
this.sessions.find(function(err, cursor){
cursor.each(function(err, d) {
d = cleanSessionData(d);
arr.push(d);
if(!d._id){
if (callback) callback(arr);
}
});
if (callback) callback(arr);
});

@@ -138,2 +140,2 @@ };

module.exports = MongoSessionStore;
module.exports = MongoSessionStore;

48

lib/databases/redis.js

@@ -17,4 +17,3 @@ var util = require(process.binding('natives').util ? 'util' : 'sys'),

prefix:'sess',
ttl: 804600,
reapInterval: 600000
ttl: 804600
};

@@ -26,7 +25,9 @@

this.prefix = options.prefix;
this.ttl = options.ttl;
if (options.db) {
self.client.select(options.db);
self.client.on("connect", function() {
this.client.select(options.db);
this.client.on("connect", function() {
self.client.send_anyways = true;

@@ -40,3 +41,3 @@ self.client.select(options.db);

self.client.on('error', function () {
this.client.on('error', function () {
self.emit('disconnect');

@@ -49,3 +50,3 @@

self.client.on('connect', function () {
this.client.on('connect', function () {
self.emit('connect');

@@ -63,3 +64,3 @@

RedisSessionStore.prototype.set = function (sid, sess, callback) {
sid = this.prefix + sid;
var prefixedSid = this.prefix + sid;

@@ -70,3 +71,3 @@ try {

this.client.setex(sid, ttl, sess, function(err, result){
this.client.setex(prefixedSid, ttl, sess, function(err, result){
if(callback){

@@ -84,5 +85,5 @@ callback(err, result);

RedisSessionStore.prototype.get = function (sid, callback) {
sid = this.prefix + sid;
var prefixedSid = this.prefix + sid;
this.client.get(sid, function(err, data){
this.client.get(prefixedSid, function(err, data){
if (err) {

@@ -119,29 +120,6 @@ if(callback){

RedisSessionStore.prototype.destroy = function(sid, callback){
sid = this.prefix + sid;
this.client.del(sid, callback);
var prefixedSid = this.prefix + sid;
this.client.del(prefixedSid, callback);
};
// RedisSessionStore.prototype.destroy = function(hash, callback) {
// this.db.remove(hash, callback);
// };
// RedisSessionStore.prototype.length = function(callback) {
// process.nextTick(function () {
// callback(this.db.length);
// });
// };
// RedisSessionStore.prototype.clear = function(callback) {
// var count = this.db.length;
// Object.keys(this.db.index).forEach(function (key) {
// this.remove(key, function (err) {
// if (err) { callback(err); return; }
// count--;
// if (count === 0) {
// callback();
// }
// });
// }, this.db);
// };
module.exports = RedisSessionStore;
{
"author": "adrai",
"name": "sessionstore",
"version": "0.3.0",
"version": "0.4.1",
"private": false,

@@ -18,8 +18,9 @@ "main": "index.js",

"devDependencies": {
"expect.js": ">= 0.1.2",
"express": ">= 2.5.0",
"memjs": ">= 0.8.4",
"mocha": ">= 1.0.1",
"mongodb": ">= 0.0.1",
"tingodb": ">= 0.0.1",
"redis": ">= 0.10.1",
"express": ">= 2.5.0",
"mocha": ">= 1.0.1",
"expect.js": ">= 0.1.2"
"tingodb": ">= 0.0.1"
},

@@ -52,5 +53,5 @@ "description": "Sessionstore is a node.js module for multiple databases. It can be very useful if you work with express or connect.",

],
"scripts" : {
"test" : "mocha"
}
}
"scripts": {
"test": "mocha"
}
}
# Introduction
[![Build Status](https://secure.travis-ci.org/adrai/sessionstore.png)](http://travis-ci.org/adrai/session)
[![Build Status](https://secure.travis-ci.org/adrai/sessionstore.svg)](http://travis-ci.org/adrai/sessionstore)

@@ -55,3 +55,32 @@ Sessionstore is a node.js module for multiple databases. It can be very useful if you work with express or connect.

## Connecting to redis
var sessionstore = require('sessionstore');
var express = require('express');
var app = express();
app.use(express.session({
store: sessionstore.createSessionStore({
type: 'redis',
host: 'localhost', // optional
port: 6379 // optional
})
}));
## Connecting to memcached
var sessionstore = require('sessionstore');
var express = require('express');
var app = express();
app.use(express.session({
store: sessionstore.createSessionStore({
type: 'memcached',
host: 'localhost', // optional
port: 11211 // optional
})
}));
# Database Support

@@ -66,2 +95,3 @@ Currently these databases are supported:

6. redis ([redis] (https://github.com/mranney/node_redis))
7. memcached ([memjs] (https://github.com/alevy/memjs))

@@ -68,0 +98,0 @@ # License

@@ -21,3 +21,3 @@ var expect = require('expect.js'),

describe('an existing db implementation of redis', function() {
describe('an existing db implementation of redis', function(done) {
it('it should return a new store', function() {

@@ -29,5 +29,3 @@ var store = sessionStore.createSessionStore({ type: 'redis' });

it('it should set and get a session', function() {
var store = sessionStore.createSessionStore({ type: 'redis' });
store.client.on('connect', function(){
sessionStore.createSessionStore({ type: 'redis' }, function(err, store){
// #set()

@@ -53,8 +51,41 @@ store.set('123', { cookie: { maxAge: 2000 }, name: 'joe' }, function(err, result){

expect(result).to.be(1);
done();
});
});
});
});
});
});
});
});
console.log('done');
describe('an existing db implementation of memcached', function(done) {
it('it should return a new store', function() {
var store = sessionStore.createSessionStore({ type: 'memcached' });
expect(store).to.be.a('object');
});
// store.client.end();
//
// console.log('done');
it('it should set and get a session', function() {
sessionStore.createSessionStore({ type: 'memcached' }, function(err, store) {
// #set()
store.set('123', { cookie: { maxAge: 2000 }, name: 'joe' }, function(err, result){
expect(err).to.be(null);
expect(result).to.be.ok();
// #get()
store.get('123', function(err, data) {
expect(data.name).to.be('joe');
// #set()
store.set('123', { cookie: { maxAge: 2000 }, name: 'jimmy' }, function(err, ok){
// #get()
store.get('123', function(err, data){
expect(data.name).to.be('jimmy');
// #destroy()
store.destroy('123', function(err, result){
expect(err).to.be(null);
expect(result).to.be(1);
done();
});

@@ -61,0 +92,0 @@ });

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc