node-async-redis

Async Redis for NodeJS

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
node-async-redis
1161.0.15 years ago5 years agoMinified + gzip package size for node-async-redis in KB

Readme

Node Redis Async - async redis client for node.js
Build Status npm Coverage Status

How to install

yarn add node-async-redis
or
npm install node-async-redis

How to use

createRedisClient

Create redis client which expose all available redis command with async prefix.
Example:
const redisClient = createRedisClient();
await redisClient.setAsync("string key", "string value");

Original functions still exist.
Example:
redisClient.set("string key", "string value");

See all commands here : https://github.com/NodeRedis/redis-commands

Create async redis client with default config

Client will automatically created with default config and read connection config from process.env
process.env.REDIS_HOST=127.0.0.1
process.env.REDIS_PORT=6379

const { createRedisClient } = require('node-async-redis');

const redisClient = createRedisClient();
redisClient.on("error", (error) => {
    console.log("Error : ", error);
})

const asyncFunction = async () => {
    await redisClient.setAsync("string key", "string value");
    const value = await redisClient.getAsync("string key");
    ...
}

Create async redis client with custom config

For available configuration please take a look here : https://github.com/NodeRedis/noderedis
const { createRedisClient } = require('node-async-redis');
const redisClient = createRedisClient({
   host: "127.0.0.1"
   port: "6379",
   enable_offline_queue: false
});

redisClient.on("error", (error) => {
    console.log("Error : ", error);
})

const asyncFunction = async () => {
    await redisClient.setAsync("string key", "string value");
    const value = await redisClient.getAsync("string key");
    ...
}

redis

Expose original redis module from : https://github.com/NodeRedis/node
redis
const { redis } = require('node-async-redis');
const originalRedisClient = redis.createClient();