npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

power-redis

v2.0.21

Published

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

Readme

power-redis

A safe, high-performance, multifunctional, and extensible Redis abstraction for Node.js.

It 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.

📚 Documentation

Full documentation is available here:
👉 https://power-redis.docs.ihor.bielchenko.com

📦 Installation

npm install power-redis

or

yarn add power-redis

🧪 Basic usage

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" }]
})();

🚀 Key Features & Advantages

✔ Strict and Predictable Key Formatting

power-redis enforces a consistent, error‑free key style:

  • Disallows invalid characters, spaces, forbidden segments, and empty sections
  • Prevents accidental wildcard collisions
  • Ensures uniform key naming across services

This dramatically reduces debugging time in multi‑team and multi‑service environments.

✔ Safe and Reliable Payload Serialization

Built‑in helpers (toPayload, fromPayload) handle:

  • JSON objects
  • Arrays
  • Numeric and boolean primitives
  • String boolean formats ("yes", "no", "true", "false")
  • Empty strings
  • Graceful fallbacks

This prevents the classic [object Object] and malformed JSON issues.

✔ High‑Level List Operations (Queues, Buffers, Streams)

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 mode

These features are ideal for queueing, batch processing, schedulers, and background jobs.

✔ SCAN‑Based Pattern Tools (Safe Alternative to KEYS)

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 + UNLINK

Usage of UNLINK improves performance for large keysets.

✔ Connection Safety Built In

checkConnection() ensures Redis is ready before any command is executed.

Environment variable REDIS_STRICT_CHECK_CONNECTION enables strict or soft connection modes.

✔ TTL Helpers & Semi‑Atomic Behaviors

  • setOne / setMany - automatic TTL support
  • pushOne / pushMany - TTL for lists
  • incr(key, ttl) - counter with TTL reset

These are extremely useful for rate‑limiters, counters, and expiring caches.

✔ Redis Streams Support

Convenience wrappers for:

  • XGROUP
  • XREADGROUP
  • SCRIPT LOAD

Works well alongside queue systems or event pipelines.

🧱 Why Not Use Raw ioredis/node‑redis?

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.

🏗️ Ideal Use Cases

  • 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

📜 License

MIT - free for commercial and private use.