Registry / storage / promise-redis

promise-redis

JSON →
library0.0.5jsnpmunverified

Tiny library (v0.0.5) that adds promise awareness to node_redis, the main Node.js Redis client. It is promise-library agnostic, allowing developers to use native JavaScript promises or any external promise library like Q, when, or Bluebird via a factory function. The library wraps node_redis commands to return promises instead of using callbacks, while preserving the original node_redis API and callback support for legacy code. It is very small and has no additional dependencies beyond node_redis.

npm install promise-redis
INSTALL
IMPORT
SIG · PROMISE-REDIS
P
promise-redis
storagejavascriptv0.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

redis (promisified)
import redis from 'promise-redis'; const client = redis();
const redis = require('promise-redis')(null);
Default export is a factory function. Call it without arguments to use native promises.
redis.createClient
const client = redis.createClient(); client.set('key', 'val').then(console.log);
const client = redis().createClient();
createClient is available on the object returned by the factory.
redis with custom promise library
const redis = require('promise-redis')(require('q').Promise);
const redis = require('promise-redis')(Q.Promise);
Pass a factory function (takes resolver) that returns a promise. For Bluebird, use function(resolver) { return new Promise(resolver); }.

Shows how to create a promisified Redis client using native promises and perform set/get operations.

const redis = require('promise-redis')(); const client = redis.createClient(); async function example() { await client.set('mykey', 'myvalue'); const value = await client.get('mykey'); console.log(value); // 'myvalue' client.quit(); } example().catch(err => console.error(err));
Debug
Known issues
deprecatedThis package is no longer maintained. Use redis v4+ built-in promise support or ioredis instead.
fix
Migrate to ioredis or update node_redis to v4 and use its native promise API.
affects: >=0.0.0
gotchaWhen using custom promise libraries, the factory function must be a function that takes a resolver function and returns a promise object. Incorrect factories will cause runtime errors.
fix
Ensure the factory matches the expected signature: function(resolver) { return new MyPromise(resolver); }.
affects: >=0.0.0
gotchaThe library does not promisify all node_redis features, such as pub/sub or monitoring commands. Callbacks are still required for events.
fix
For pub/sub, use the traditional callback-based approach or switch to ioredis which fully supports promises.
affects: >=0.0.0
breakingThe exported value is a factory function, not a direct redis client. Calling require('promise-redis')() returns a modified redis object.
fix
Always invoke the factory: const redis = require('promise-redis')();
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: redis.createClient is not a function
Calling require('promise-redis') without invoking the factory: const redis = require('promise-redis');
fix
const redis = require('promise-redis')(); // invoke the factory
TypeError: client.set(...).then is not a function
Using native node_redis without promisification, or passing an invalid promise factory.
fix
Ensure you called the factory: const redis = require('promise-redis')(); and use the returned redis object.
Error: No promise library provided or native Promise not available
Running in an environment without native Promise and not providing a factory function.
fix
Provide a promise factory: require('promise-redis')(require('bluebird'));
Upgrade
Version history
0.0.5latest on npm
Audit
Dependencies
redisrequiredpeer runtime dependency: need node_redis to work
Agent activity
17 hits · last 30 days
node
16
Amazon
1
Resources
promise-redis — npm install promise-redis · libregistry