Redis client with pooled connections and promises
A redis client with pooled connections and promises.
- Don't use
subscribewith it just yet. That needs to use a client apart from the pool. It hasn't been programmed in yet.
- Virtually no tests.
npm install dis-redis
var Dis = require"dis-redis";var dis = ; // more on that below...disget"some:key"thencallback errorHandler // .then() ... and so on.
Either pass a valid redis
url string, an
options object or both.
In the form of
port are not required)
options.hostname(String) - represents the redis server hostname to connect to.
options.port(Number) - represents the redis server port to connect to.
options.password(String) - if auth is required.
Any other options usually accepted by node_redis will be passed along.
Any of these in
options.pool will be passed along to node-pool.
options.pool.max(Number) - maximum number of acquirable connections.
options.pool.min(Number) - minimum number of connections to hold.
options.pool.idleTimeoutMillis(Number) - time in milliseconds before releasing a idle connection
Executing redis commands uses the same syntax as node_redis.
Dis uses Q as its promises implementation. Here's how it works:
var dis =disget"some:key"then// Do something with `value`// An error occurred. Handle it!;
Due to the blocking nature operations (
BRPOPLPUSH), it's best to have a connection pool at our disposal to perform other commands while waiting.
For fun (and legibility).
Licensed under MIT license
Copyright (c) 2013 MongoHQ Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.