connect-redis
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -0,1 +1,9 @@ | ||
3.2.0 / 2016-12-24 | ||
================== | ||
- Implement .all(), introduce .ids() [anotherpit] | ||
- Allow .destroy to take an array of sids [barisusakli] | ||
- Update docs [kidlj] | ||
- Document defaults for ttl and db [pasieronen] | ||
3.1.0 / 2016-06-16 | ||
@@ -2,0 +10,0 @@ ================== |
@@ -79,3 +79,3 @@ /*! | ||
} | ||
// logErrors | ||
@@ -90,3 +90,3 @@ if(options.logErrors){ | ||
} | ||
this.client.on('error', options.logErrors); | ||
this.client.on('error', options.logErrors); | ||
} | ||
@@ -212,5 +212,14 @@ | ||
RedisStore.prototype.destroy = function (sid, fn) { | ||
sid = this.prefix + sid; | ||
debug('DEL "%s"', sid); | ||
this.client.del(sid, fn); | ||
if (Array.isArray(sid)) { | ||
var multi = this.client.multi(); | ||
var prefix = this.prefix; | ||
sid.forEach(function (s) { | ||
multi.del(prefix + s); | ||
}); | ||
multi.exec(fn); | ||
} else { | ||
sid = this.prefix + sid; | ||
this.client.del(sid, fn); | ||
} | ||
}; | ||
@@ -243,3 +252,71 @@ | ||
/** | ||
* Fetch all sessions' ids | ||
* | ||
* @param {Function} fn | ||
* @api public | ||
*/ | ||
RedisStore.prototype.ids = function (fn) { | ||
var store = this; | ||
var pattern = store.prefix + '*'; | ||
var prefixLength = store.prefix.length; | ||
if (!fn) fn = noop; | ||
debug('KEYS "%s"', pattern); | ||
store.client.keys(pattern, function (er, keys) { | ||
if (er) return fn(er); | ||
debug('KEYS complete'); | ||
keys = keys.map(function (key) { | ||
return key.substr(prefixLength); | ||
}); | ||
return fn(null, keys); | ||
}); | ||
}; | ||
/** | ||
* Fetch all sessions | ||
* | ||
* @param {Function} fn | ||
* @api public | ||
*/ | ||
RedisStore.prototype.all = function (fn) { | ||
var store = this; | ||
var pattern = store.prefix + '*'; | ||
var prefixLength = store.prefix.length; | ||
if (!fn) fn = noop; | ||
debug('KEYS "%s"', pattern); | ||
store.client.keys(pattern, function (er, keys) { | ||
if (er) return fn(er); | ||
debug('KEYS complete'); | ||
var multi = store.client.multi(); | ||
keys.forEach(function (key) { | ||
multi.get(key); | ||
}); | ||
multi.exec(function (er, sessions) { | ||
if (er) return fn(er); | ||
var result; | ||
try { | ||
result = sessions.map(function (data, index) { | ||
data = data.toString(); | ||
data = store.serializer.parse(data); | ||
data.id = keys[index].substr(prefixLength); | ||
return data; | ||
}); | ||
} catch (er) { | ||
return fn(er); | ||
} | ||
return fn(null, result); | ||
}); | ||
}); | ||
}; | ||
return RedisStore; | ||
}; |
{ | ||
"name": "connect-redis", | ||
"description": "Redis session store for Connect", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"author": "TJ Holowaychuk <tj@vision-media.ca>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -27,9 +27,15 @@ [![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) | ||
A Redis client is required. An existing client can be passed directly using the `client` param or created for you using the `host`, `port`, or `socket` params. - `client` An existing client - `host` Redis server hostname - `port` Redis server portno - `socket` Redis server unix_socket - `url` Redis server url | ||
A Redis client is required. An existing client can be passed directly using the `client` param or created for you using the `host`, `port`, or `socket` params. | ||
- `client` An existing client | ||
- `host` Redis server hostname | ||
- `port` Redis server portno | ||
- `socket` Redis server unix_socket | ||
- `url` Redis server url | ||
The following additional params may be included: | ||
- `ttl` Redis session TTL (expiration) in seconds | ||
- `ttl` Redis session TTL (expiration) in seconds. Defaults to session.maxAge (if set), or one day. | ||
- `disableTTL` Disables setting TTL, keys will stay in redis until evicted by other means (overides `ttl`\) | ||
- `db` Database index to use | ||
- `db` Database index to use. Defaults to Redis's default (0). | ||
- `pass` Password for Redis authentication | ||
@@ -36,0 +42,0 @@ - `prefix` Key prefix defaulting to "sess:" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20239
405
81