yarn add node-async-redis
or
npm install node-async-redis
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
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");
...
}
For available configuration please take a look here : https://github.com/NodeRedis/node_redis
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");
...
}
Expose original redis module from : https://github.com/NodeRedis/node_redis
const { redis } = require('node-async-redis');
const originalRedisClient = redis.createClient();