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

@thzero/library_server_repository_redis

v0.19.1

Published

![GitHub package.json version](https://img.shields.io/github/package-json/v/thzero/library_server_repository_redis) ![David](https://img.shields.io/david/thzero/library_server_repository_redis) [![License: MIT](https://img.shields.io/badge/License-MIT-yel

Readme

GitHub package.json version David License: MIT

library_server_repository_redis

The Redis repository base for @thzero/library_server.

This package brings no Redis driver of its own. It handles configuration lookup, connection caching and the mutex around opening a connection, and leaves the driver to a subclass. Use @thzero/library_server_repository_redis_ioredis unless you have a reason to bind a different client.

Requirements

NodeJs

NodeJs version 22+

Redis

A reachable Redis server. Nothing in this package starts or provisions one.

Installation

NPM

npm install @thzero/library_server_repository_redis

Peer dependencies

  • @thzero/library_common
  • @thzero/library_common_service
  • @thzero/library_server

What it provides

index.js — default export RedisRepository, extending Repository from @thzero/library_server.

| Member | Purpose | |---|---| | getClientName() | The client's name, 'redis' by default. Override to point at a different db.* config block. | | _getClient(correlationId, clientName) | Returns a connected client, opening one on first use. clientName is optional and falls back to _initClientName(). | | _initClientName() | The name used as the connection cache key. Returns getClientName(). | | _initializeClient(correlationId, clientName) | Resolves the connection config, builds the client through the subclass, and caches it. | | _initializeClientConnection(correlationId, connectionInfo, clientName, config) | Abstract. Throws NotImplementedError. A subclass builds and returns the driver's client here. |

Clients are cached in a static map keyed by client name, so every repository instance in the process shares one connection per name. Opening is guarded by a static mutex, so concurrent first calls open exactly one.

Configuration

The connection block is read from db.<getClientName()>.connection and passed verbatim to the subclass — this package never interprets it, so its shape is whatever your driver accepts.

{
    "app": {
        "db": {
            "redis": {
                "connection": {
                    "host": "127.0.0.1",
                    "port": 6379,
                    "username": "<username>",
                    "password": "<password>",
                    "db": 0
                }
            }
        }
    }
}

A connection string is equally valid if the driver takes one:

{ "app": { "db": { "redis": { "connection": "redis://127.0.0.1:6379" } } } }

A missing or empty connection fails at boot with connectionInfo is empty, rather than at the first query.

Wiring it up

Subclass a driver binding rather than this package directly:

import BaseRedisRepository from '@thzero/library_server_repository_redis_ioredis/index.js';

class RegistryRepository extends BaseRedisRepository {
    async publish(correlationId, channel, message) {
        this._enforceNotEmpty('RegistryRepository', 'publish', channel, 'channel', correlationId);

        const client = await this._getClient(correlationId);
        await client.publish(correlationId, channel, JSON.stringify(message));
    }
}

Register it with the injector from _initRepositories in your BootMain derived class, or from a boot plugin's initRepositories.

Development

npm run lint       # eslint .
npm run lint:fix   # eslint . --fix
npm test           # node --test "test/*.test.js"