Production-grade Redis abstraction for Node.js with strict key formatting, safe JSON serialization, advanced list/queue operations, SCAN-based pattern tools, TTL helpers, batch UNLINK deletion, and Redis Streams support. Perfect for high-load microservice
npm install power-redisIt provides a set of advanced Redis operations that are not available in standard clients, including consistent key-formatting utilities, safe serialization, bulk operations, and more.
This library is built with a focus on stability, clarity, and real-world application needs, making Redis usage more maintainable and convenient in large distributed systems.
Full documentation is available here:
👉 https://power-redis.docs.ihor.bielchenko.com
``bash`
npm install power-redis
or
`bash`
yarn add power-redis
`ts
import { PowerRedis } from 'power-redis';
import Redis from 'ioredis';
class MyRedis extends PowerRedis {
public redis = new Redis({ host: '127.0.0.1', port: 6379 });
}
const redis = new MyRedis();
(async () => {
await redis.setMany([
{
key: 'key1',
value: 'value 1'
},
{
key: 'key2',
value: 'value 2'
}
], 3600);
const keys = await redis.keys('key_prefix:1:*'); // [ "key_prefix:1:key1", "key_prefix:1:key2" ]
const data = await redis.getMany('key_prefix:1:*'); // [{ key1: "value 1" }, { key2: "value 2" }]
})();
`
This dramatically reduces debugging time in multi‑team and multi‑service environments.
, fromPayload) handle:
- JSON objects
- Arrays
- Numeric and boolean primitives
- String boolean formats ("yes", "no", "true", "false")
- Empty strings
- Graceful fallbacksThis prevents the classic
[object Object] and malformed JSON issues.$3
Includes utilities not found in basic Redis clients:- lpopCountCompat - a safe polyfill for
LPOP key count
- getListIterator - async chunk‑based iteration over large lists
- pushOne / pushMany - with optional TTL support
- getList(remove=true/false) - consumption or read‑only modeThese features are ideal for queueing, batch processing, schedulers, and background jobs.
$3
power-redis offers efficient mass‑operations without blocking Redis:-
keys(pattern, limit, scanSize) - safe pattern scanning
- getMany(pattern) - batch MGET with chunking
- dropMany(pattern) - deletion via SCAN + UNLINKUsage of
UNLINK improves performance for large keysets.$3
checkConnection() ensures Redis is ready before any command is executed.Environment variable
REDIS_STRICT_CHECK_CONNECTION enables strict or soft connection modes.$3
- setOne / setMany - automatic TTL support
- pushOne / pushMany - TTL for lists
- incr(key, ttl) - counter with TTL resetThese are extremely useful for rate‑limiters, counters, and expiring caches.
$3
Convenience wrappers for:
- XGROUP
- XREADGROUP
- SCRIPT LOAD`Works well alongside queue systems or event pipelines.
Typical Redis clients only expose low‑level commands.
Real‑world applications quickly accumulate duplicated logic, such as:
- inconsistent key naming
- unsafe SCAN/KEYS usage
- repeated JSON encode/decode
- list pagination boilerplate
- TTL handling logic
- mismatched connection state checks
power-redis solves these problems with a clean, unified API layer that keeps your microservices consistent and safe.
- Node.js / TypeScript microservice ecosystems
- Distributed architectures
- High‑volume Redis workloads
- Queueing and background processing
- Monitoring, tracking, real‑time data pipelines
- Systems requiring predictable Redis key structure