This package is for those who want to use the node-redis version 3.x, that supports createClient configuration options like: prefix
, rename_commands
, but also want the full promise and type definitions support of version 4.x.
This package is a wrapper built on top of redis-v3 (github). Do checkout the docs for that package for details related to node-redis.
npm install redis-v3-promise
Supported for Node >= 12.x
const redis = require('redis-v3-promise');
const client = redis.createClient();
// client.native is the native client created by node-redis lib
client.native.on('error', function(error) {
console.error(error);
});
client
.set('key', 'value')
.then(console.log)
.catch(console.error);
client
.get('key')
.then(console.log)
.catch(console.error);
Important:
client.native
is the native client created by node-redis lib. For listening to errors or using all other functions provided by the native redis client (other than the redis commands) do use theclient.native
object.For full list of supported commands, options and docs, please check this: redis-v3
In case the native v3 redis object is required (assertions for tests, etc), use this:
const {
AbortError,
AggregateError,
ReplyError,
} = require('redis-v3-promise').v3;