Registry / database / async-redis

async-redis

JSON →
library2.0.0jsnpmunverified

async-redis is a lightweight wrapper over the node_redis library, providing first-class async/await and Promise support for Redis operations in Node.js. Version 2.0.0 is the current stable release, targeting Node >=7.6.0. Unlike using promisify manually on node_redis, async-redis offers a drop-in replacement that automatically returns Promises for every command, supports decorating existing clients, and ships TypeScript definitions. It is a minimal, focused alternative to ioredis, suitable for projects already using node_redis that want async support without migrating to a different client.

npm install async-redis
INSTALL
IMPORT
SIG · ASYNC-REDIS
A
async-redis
databasejavascriptv2.0.0
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.

asyncRedis (default export)
import asyncRedis from 'async-redis'
const asyncRedis = require('async-redis').default
ESM default import works; CommonJS requires the default export directly.
decorate
import asyncRedis from 'async-redis'; asyncRedis.decorate(client)
import { decorate } from 'async-redis'
decorate is a method on the default export, not a named export.
createClient
import asyncRedis from 'async-redis'; asyncRedis.createClient()
import { createClient } from 'async-redis'
createClient is attached to the default export, not a named export.
RedisClient type
import type { RedisClient } from 'async-redis'
import { RedisClient } from 'async-redis'
RedisClient is exported as a type only, not a value.

Shows async/await usage with async-redis: create client, set and get a key, then clean up.

import redis from 'redis'; import asyncRedis from 'async-redis'; const client = asyncRedis.createClient(); client.on('error', (err) => console.error('Redis error:', err)); async function run() { await client.set('key', 'value'); const val = await client.get('key'); console.log(val); // 'value' await client.del('key'); client.quit(); } run().catch(console.error);
Debug
Known issues
gotchaasync-redis is a wrapper over node_redis v2.x; it does not support node_redis v3+ which has native promises.
fix
Use node_redis v2.x as a peer dependency. For v3+, consider using node_redis directly or ioredis.
affects: >=2.0.0
deprecatedClient callback-based events (e.g., client.on('error')) still work, but Promise-based error handling is recommended.
fix
Use catch on promises instead of relying solely on event listeners.
affects: >=1.0.0
gotchaThe decorate function does not mutate the original client; it returns a new promisified client.
fix
Use the return value of decorate: const asyncClient = asyncRedis.decorate(client);
affects: >=1.0.0
gotchaAll redis commands are promisified, including blocking commands like BRPOP. They will not block the event loop but may cause unexpected behavior if not awaited.
fix
Always await commands that return promises, especially blocking ones, to avoid unhandled rejections.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: client.get is not a function
Using async-redis but not calling createClient or decorate on an existing client.
fix
Ensure you use asyncRedis.createClient() or asyncRedis.decorate(client) and use the returned client.
UnhandledPromiseRejectionWarning: Error: Redis connection to 127.0.0.1:6379 failed
Redis server not running or connection issue.
fix
Start Redis server or check connection settings.
TypeError: asyncRedis.decorate is not a function
Importing async-redis incorrectly (e.g., named import of decorate).
fix
Use default import: import asyncRedis from 'async-redis' then asyncRedis.decorate(client).
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
redisrequiredasync-redis wraps node_redis; redis is a required peer dependency
Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources