Socket
Socket
Sign inDemoInstall

connect-redis

Package Overview
Dependencies
Maintainers
3
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

connect-redis - npm Package Compare versions

Comparing version 2.5.1 to 3.0.0

5

History.md
3.0.0 / 2015-10-03
==================
* Update node_redis to 2.0, reinstate `url` option [fintura]
2.5.1 / 2015-09-18

@@ -3,0 +8,0 @@ ==================

21

lib/connect-redis.js

@@ -57,2 +57,3 @@ /*!

options = options || {};
options.max_attempts = 2;
Store.call(this, options);

@@ -67,18 +68,4 @@ this.prefix = options.prefix == null

if (options.url) {
console.error('Warning: "url" param is deprecated and will be removed in a later release: use redis-url module instead');
var url = require('url').parse(options.url);
if (url.protocol === 'redis:') {
if (url.auth) {
var userparts = url.auth.split(':');
options.user = userparts[0];
if (userparts.length === 2) {
options.pass = userparts[1];
}
}
options.host = url.hostname;
options.port = url.port;
if (url.pathname) {
options.db = url.pathname.replace('/', '', 1);
}
}
options.port = options.url;
options.host = options;
}

@@ -243,3 +230,3 @@

if (!fn) fn = noop;
if (store.disableTTL) return fn()
if (store.disableTTL) return fn();

@@ -246,0 +233,0 @@ var ttl = getTTL(store, sess);

{
"name": "connect-redis",
"description": "Redis session store for Connect",
"version": "2.5.1",
"version": "3.0.0",
"author": "TJ Holowaychuk <tj@vision-media.ca>",

@@ -16,4 +16,4 @@ "contributors": [

"dependencies": {
"debug": "^1.0.4",
"redis": "^0.12.1"
"debug": "^2.2.0",
"redis": "^2.0.1"
},

@@ -23,7 +23,7 @@ "devDependencies": {

"bluebird": "^2.3.2",
"eslint": "^0.9.2",
"eslint": "^1.6.0",
"express-session": "^1.9.1",
"ioredis": "^1.7.5",
"istanbul": "^0.3.2",
"tape": "^3.0.3"
"tape": "^4.2.1"
},

@@ -39,4 +39,4 @@ "engines": {

"bench": "node bench/redisbench.js",
"lint": "eslint --reset index.js test lib bench"
"lint": "eslint index.js test lib bench"
}
}

@@ -1,16 +0,23 @@

# Connect Redis
[![npm](https://img.shields.io/npm/v/connect-redis.svg)](https://npmjs.com/package/connect-redis) [![Dependencies](https://img.shields.io/david/tj/connect-redis.svg)](https://david-dm.org/tj/connect-redis) ![Downloads](https://img.shields.io/npm/dm/connect-redis.svg)
connect-redis is a Redis session store backed by [node_redis](http://github.com/mranney/node_redis), and is insanely fast :). Requires redis >= `2.0.0` for the _SETEX_ command.
**connect-redis** is a Redis session store backed by [node_redis](http://github.com/mranney/node_redis), and is insanely fast :). Requires redis >= `2.0.0` for the _SETEX_ command.
## Installation
## Setup
$ npm install connect-redis
```sh
npm install connect-redis express-session
```
### A note for Express 3.x users
Pass the `express-session` store into `connect-redis` to create a `RedisStore` constructor.
In order to use the latest `connect-redis` you also have to use [`express-session`](https://github.com/expressjs/session) instead of the default connect `session` middleware.
```js
var session = require('express-session');
var RedisStore = require('connect-redis')(session);
$ npm install express-session
app.use(session({
store: new RedisStore(options),
secret: 'keyboard cat'
}));
```
Then follow the usage instructions below.

@@ -24,2 +31,3 @@ ## Options

- `socket` Redis server unix_socket
- `url` Redis server url

@@ -38,14 +46,2 @@ The following additional params may be included:

## Usage
Pass the `express-session` store into `connect-redis` to create a `RedisStore` constructor.
var session = require('express-session');
var RedisStore = require('connect-redis')(session);
app.use(session({
store: new RedisStore(options),
secret: 'keyboard cat'
}));
## Custom Redis clients

@@ -59,6 +55,2 @@

#### Can I use a URL scheme to make a connection?
Since `node_redis` which this library wraps does not include the ability to create a client from a URL. Neither does this library. However, there's a [separate module](https://github.com/ddollar/redis-url) that can be used in conjunction to get this behavior.
#### How do I handle lost connections to Redis?

@@ -65,0 +57,0 @@

@@ -34,3 +34,3 @@ var P = require('bluebird');

store.client.end();
return redisSrv.disconnect()
return redisSrv.disconnect();
});

@@ -58,3 +58,3 @@ }

var client = redis.createClient(8543, 'localhost');
var store = new RedisStore({ client: client })
var store = new RedisStore({ client: client });
return lifecycleTest(store, t);

@@ -65,3 +65,3 @@ });

var client = ioRedis.createClient(8543, 'localhost');
var store = new RedisStore({ client: client })
var store = new RedisStore({ client: client });
return lifecycleTest(store, t);

@@ -90,7 +90,7 @@ });

t.equal(socketStore.client.address, 'word', 'sets socket address');
socketStore.client.end()
socketStore.client.end();
var hostNoPort = new RedisStore({ host: 'host' });
t.equal(hostNoPort.client.address, 'host:6379', 'sets default port');
hostNoPort.client.end()
hostNoPort.client.end();

@@ -102,6 +102,5 @@ return lifecycleTest(store, t);

var store = P.promisifyAll(new RedisStore({ port: 8543 }));
return store.setAsync('123', { cookie: { maxAge: 2000 }, name: 'tj' })
.catch(function (er) {
t.ok(/failed/.test(er.message), 'failed connection');
t.ok(/broken/.test(er.message), 'failed connection');
store.client.end();

@@ -120,6 +119,6 @@ });

t.equal(serializer.stringify('UnitTest'), 'XXX"UnitTest"');
t.equal(serializer.parse(serializer.stringify("UnitTest")), 'UnitTest');
t.equal(serializer.parse(serializer.stringify('UnitTest')), 'UnitTest');
var store = new RedisStore({ port: 8543, serializer: serializer });
return lifecycleTest(store, t);
return lifecycleTest(store, t);
});

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