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

@filamentjs/redis

v0.1.0

Published

Shared Redis connection and atomic adapter support for FilamentJS policies

Readme

@filamentjs/redis

Shared Redis connection lifecycle, versioned key construction, and atomic storage adapters for FilamentJS policies. Applications may let the package own a node-redis client or inject a compatible client and retain ownership.

Key features

  • Owned or injected Redis client lifecycle with health checks and cleanup.
  • Versioned, escaped standalone and Redis Cluster key construction.
  • Atomic rate-limiting, idempotency, and OAuth Lua adapters.
  • Structural policy contracts without runtime dependencies on policy packages.
  • A published wire inventory for every command, script, record, reply, TTL, and failure rule.

Quick start

npm install @filamentjs/redis
import { createRedisConnection, createRedisKeyspace } from "@filamentjs/redis";

const redis = createRedisConnection({ url: process.env.REDIS_URL });
await redis.open();

const keys = createRedisKeyspace({ namespace: "my-service" });
console.log(keys.key("rate-limiting", "group-a", "principal-123"));

await redis.close();

Requires Node 24+. This package has no Filament runtime peer and uses [email protected] as its one production dependency. Treat Redis URLs as secrets because they may contain credentials.

How it works and options

This package is intentionally not a generic key/value policy store. Each policy defines the operation and atomicity it needs; this package supplies the standard Redis implementation of that structural contract.

An injected client is connected by open() when necessary but is never closed by this package. A package-created client is closed by close(). Treat Redis URLs as secrets: they may contain credentials and this package never logs them.

The connection emits errors to onError. Its default exporter is console.error; production applications should provide a structured exporter that redacts deployment details. ping() fails closed on any reply other than PONG.

Public API

| Surface | Meaning | | --- | --- | | createRedisConnection, openRedisConnection, RedisConnection | Owned/injected client lifecycle, readiness, health, PING, and cleanup. | | createRedisKeyspace, RedisKeyspace | Versioned, escaped normal and Redis Cluster key construction. | | createRedisRateLimitStore | Server-time, atomic all-or-none fixed-window adapter. | | createRedisIdempotencyStore | Atomic acquire and compare-and-complete lease adapter. | | createRedisOAuthStore | Atomic one-use transaction/code and opaque-token adapter. | | RedisClient | Minimal structural client surface required by this package. |

Policy adapters implement the public structural store types from their owning packages; compile-time fixtures guard compatibility without creating runtime dependencies. Adapter close() does not close the shared connection. The application closes the connection once after all policies stop.

Every direct command, script, key, argument, reply, TTL, atomicity boundary, and failure rule is documented in redis.md. Adapter errors reject and owning policies decide their documented fail-open/fail-closed behavior. No automatic retry is performed because an ambiguous write can change security or accounting state.

The default demo only connects when REDIS_URL is explicitly set and never creates, flushes, or deletes a service. The conditional real-server suite uses the same variable. The full suite passes against Redis 6.2.23, including contention, one-use consumption, and expiry. Reconnect, ambiguous-failure, and cluster-deployment tests remain required before distributed-production claims.

Development and demo

From a source checkout:

npm test
npm run example
npm run demo

The unattended demo always shows safe versioned key construction. When REDIS_URL is set it also performs a non-destructive PING, closes the owned connection, and exits; it never reads, writes, flushes, or deletes keys.

There is no pre-0.1 migration contract. Serialized envelopes and keyspaces are versioned so future migrations can be explicit.

License

ISC