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

deepbase-redis

v3.2.0

Published

⚡ DeepBase Redis (vanilla) - driver

Readme

deepbase-redis

Vanilla Redis driver for DeepBase (no modules required).

Installation

npm install deepbase deepbase-redis

Prerequisites

Requires standard Redis (no modules needed):

docker run -d -p 6379:6379 --name redis redis:latest

Note: This driver works with vanilla Redis. For RedisJSON support, use deepbase-redis-json instead.

Description

Stores data in Redis using standard string operations with JSON serialization. Perfect for:

  • ✅ High-performance caching
  • ✅ Real-time applications
  • ✅ Session storage
  • ✅ Works with any Redis installation
  • ✅ No modules required

Usage

import DeepBase from 'deepbase';
import RedisDriver from 'deepbase-redis';

const db = new DeepBase(new RedisDriver({
  url: 'redis://localhost:6379',
  prefix: 'myapp'
}));

await db.connect();

await db.set('users', 'alice', { name: 'Alice', age: 30 });
const alice = await db.get('users', 'alice');

Options

new RedisDriver({
  url: 'redis://localhost:6379',    // Redis connection URL
  prefix: 'db',                     // Key prefix (or use 'name')
  nidAlphabet: 'ABC...',           // Alphabet for ID generation
  nidLength: 10                     // Length of generated IDs
})

Data Structure

Data is stored as JSON strings in Redis:

// Keys created
myapp:users     -> '{"alice": {...}, "bob": {...}}'
myapp:config    -> '{"theme": "dark", "lang": "en"}'

Differences from deepbase-redis-json

This vanilla driver:

  • ✅ Works with any Redis installation
  • ✅ No modules required
  • ✅ Simpler deployment
  • ❌ No atomic JSON path operations
  • ❌ Entire values must be read/written

The RedisJSON driver (deepbase-redis-json):

  • ✅ Atomic JSON path operations
  • ✅ More efficient for large nested objects
  • ❌ Requires Redis Stack or RedisJSON module

Features

JSON Serialization

Uses standard JSON serialization:

await db.set('users', 'alice', { name: 'Alice', age: 30 });
// Stored as: '{"alice": {"name": "Alice", "age": 30}}'

Nested Operations

Supports nested path operations:

await db.set('users', 'alice', 'address', { city: 'NYC' });
// Reads full object, modifies, and writes back

Increment/Decrement

Basic increment operations:

await db.inc('stats', 'views', 1);
await db.dec('stats', 'views', 1);

Key Scanning

Efficiently scans keys with patterns:

const allUsers = await db.get('users');
// Scans all keys matching prefix

Connection String Formats

// Local
url: 'redis://localhost:6379'

// With password
url: 'redis://:password@localhost:6379'

// With database number
url: 'redis://localhost:6379/0'

// Redis Cloud
url: 'redis://username:password@host:port'

// TLS/SSL
url: 'rediss://host:port'

Performance

Redis is extremely fast:

  • Reads: Sub-millisecond response times
  • Writes: Thousands of operations per second
  • In-memory: Data stored in RAM with optional persistence
  • Simple: No complex JSON path operations

Use Cases

Session Storage

const sessions = new DeepBase(new RedisDriver({ prefix: 'session' }));
await sessions.set(sessionId, 'user', userData);

Real-time Stats

const stats = new DeepBase(new RedisDriver({ prefix: 'stats' }));
await stats.inc('page', 'views', 1);

Cache Layer

const cache = new DeepBase([
  new RedisDriver({ prefix: 'cache' }),
  new MongoDriver({ url: '...' })
]);

Best Practices

  1. Use as cache layer - Not as primary storage
  2. Small to medium objects - Full objects are read/written
  3. Monitor memory usage - Redis is in-memory
  4. Enable persistence - RDB or AOF for durability
  5. Use with persistent drivers - MongoDB or JSON backup

Persistence Options

Redis supports:

  • RDB: Periodic snapshots
  • AOF: Append-only file for durability

Configure in Redis:

docker run -d -p 6379:6379 \
  -v redis-data:/data \
  redis:latest \
  --appendonly yes

Error Handling

try {
  await db.connect();
} catch (error) {
  console.error('Redis connection failed:', error);
  // Fallback to other drivers
}

When to Use

Use deepbase-redis (this driver) when:

  • You have standard Redis
  • You want simple deployment
  • Your objects are small to medium sized
  • You don't need atomic JSON operations

Use deepbase-redis-json when:

  • You have Redis Stack
  • You need atomic JSON path operations
  • You work with large nested objects
  • You want optimal performance for partial updates

License

MIT - Copyright (c) Martin Clasen