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

@sebspark/memredis

v1.0.3

Published

An in-memory implementation of Redis. Fully compatible with the Redis client API for development, testing, and scenarios where an in-memory store suffices.

Readme

@sebspark/memredis

An in-memory implementation of Redis. Fully compatible with the Redis client API for development, testing, and scenarios where an in-memory store suffices.

Features

  • Full Redis-like API — supports strings, hashes, lists, sets, and sorted sets with optional expiration
  • Pub/Sub — subscribe to channels and publish messages, coordinating across multiple in-memory clients
  • WRONGTYPE enforcement — throws when the wrong command type is used on a key, matching real Redis behaviour
  • Test container parity — e2e tests verify behavior matches real Redis exactly

Installation

yarn add @sebspark/memredis

Usage

Basic example

import { MemRedis } from '@sebspark/memredis'

const client = new MemRedis()

// Set and get
await client.set('key', 'value')
const value = await client.get('key') // 'value'

// Expiration
await client.setEx('temp-key', 60, 'expires in 60 seconds')
const ttl = await client.ttl('temp-key') // ~60

// Delete
await client.del('key')

Hashes

const client = new MemRedis()

await client.hSet('user:1', { name: 'Alice', age: '30' })
const user = await client.hGetAll('user:1') // { name: 'Alice', age: '30' }
await client.hDel('user:1', 'age')

Lists, sets, sorted sets

const client = new MemRedis()

// Lists
await client.lPush('queue', ['job1', 'job2'])
const job = await client.lPop('queue') // 'job2'

// Sets
await client.sAdd('tags', ['a', 'b', 'c'])
const members = await client.sMembers('tags') // ['a', 'b', 'c']

// Sorted sets
await client.zAdd('leaderboard', { score: 100, value: 'alice' })
const top = await client.zRangeWithScores('leaderboard', 0, 0, { REV: true })

Pub/Sub

All MemRedis instances share the same pub/sub bus, matching real Redis behaviour where all clients connect to the same server.

If you type against IPersistor, pub/sub subscription methods use transport-specific return values. MemRedis returns subscription counts, while redis clients resolve those methods without a value.

import { MemRedis } from '@sebspark/memredis'

const publisher = new MemRedis()
const subscriber = new MemRedis()

await subscriber.subscribe('events', (message) => {
  console.log('Received:', message)
})

await publisher.publish('events', 'hello world')

Development and testing

Use MemRedis in tests to avoid Docker overhead while still maintaining Redis-compatible behavior. The e2e test suite verifies MemRedis behavior matches actual Redis exactly.

import { describe, it, expect } from 'vitest'
import { MemRedis } from '@sebspark/memredis'

describe('my cache', () => {
  it('stores and retrieves values', async () => {
    const cache = new MemRedis()
    await cache.set('key', 'value')
    expect(await cache.get('key')).toBe('value')
  })
})

Limitations

  • Single-process only — not suitable for multi-process or distributed scenarios
  • No persistence — data is lost when the process exits
  • No cluster support
  • No Redis modules

For production use cases requiring Redis features, use the official redis package.