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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sapientpro/nestjs-redis

v1.0.0

Published

Lightweight Redis module for NestJS using ioredis and ready-to-inject Redis client.

Readme

@sapientpro/nestjs-redis

NPM Package

Lightweight Redis module for NestJS built on top of ioredis. It integrates with @nestjs/config, provides a connected Redis client for injection, and supports TLS via simple environment variables.

Installation

npm install @sapientpro/nestjs-redis ioredis

Quick start

  1. Import RedisModule and inject Redis (ioredis client)
// app.module.ts
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { RedisModule } from '@sapientpro/nestjs-redis';

@Module({
  imports: [
    ConfigModule.forRoot({ isGlobal: true }),
    RedisModule,
  ],
})
export class AppModule {}
// some.service.ts
import { Injectable } from '@nestjs/common';
import Redis from 'ioredis';

@Injectable()
export class SomeService {
  constructor(private readonly redis: Redis) {}

  async setValue(key: string, value: string) {
    await this.redis.set(key, value);
  }

  async getValue(key: string) {
    return this.redis.get(key);
  }
}
  1. Configure via environment variables (loaded by @nestjs/config)

The module registers a configuration namespace redis built from these env variables:

  • REDIS_HOST (default: localhost)
  • REDIS_PORT (default: 6379)
  • REDIS_DB (default: 0)
  • REDIS_PASSWORD (optional)
  • REDIS_TLS ("1", "on", or "true" to enable TLS)

Example .env:

REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_DB=0
# REDIS_PASSWORD=your_password
# REDIS_TLS=true
  1. Using the ioredis namespace re-export (optional)

If you need ioredis types or utilities directly but want to avoid version conflicts, you can import from this package:

import { ioredis } from '@sapientpro/nestjs-redis';

const KeyPrefix: ioredis.KeyPrefix = { prefix: 'app:' };

API Summary

  • RedisModule: Nest module that provides a connected ioredis client.
  • Inject token: use the Redis class from ioredis as the provider token.
  • Config: provided via @nestjs/config under the redis namespace (see src/config.ts in the package).

Notes

  • The module waits for the initial connection before making the client available via DI. If connection fails at startup, the module provider factory will reject and surface the error.
  • maxRetriesPerRequest is set to null by default to allow commands in certain states (like blocking commands) without forced retries. Adjust to your needs if you rely on different retry semantics.

License

MIT © SapientPro