Supercharge Your App with Redis Stack

Supercharge Your App with Redis Stack

Ralph Nguyen

Redis has long been known as the fastest key-value store on the planet. But Redis Stack takes it to a whole new level — turning Redis into a multi-model, real-time data platform ready for modern application needs like AI, search, analytics, IoT, and personalization.

This blog post is your practical, hands-on guide to Redis Stack — what it is, why it's powerful, and how to use it in Node.js projects.

What Is Redis Stack?

Redis Stack bundles the core Redis engine with powerful modules:

Module Purpose
RedisJSON Store and query nested JSON documents
RediSearch Full-text search, filters, secondary indexes
RedisTimeSeries Time-series data, real-time analytics
RedisGraph Graph database for connected data
RedisBloom Probabilistic structures like Bloom Filters
RedisVector Vector similarity search for AI use cases

1. RedisJSON – Store and Query Nested JSON

RedisJSON allows structured, partial document operations.

Setup

npm install redis
import { createClient } from 'redis';

const client = createClient();
await client.connect();

Set & Get JSON

await client.json.set('user:1', '$', {
  name: 'Alice',
  age: 30,
  address: { city: 'NYC', zip: '10001' }
});

const city = await client.json.get('user:1', {
  path: '$.address.city'
});
console.log(city); // ["NYC"]

Modify Only Part of a JSON

await client.json.set('user:1', '$.address.zip', '10002');

2. RediSearch – Full-Text Search + Indexing

Build powerful search on top of RedisJSON data.

Create an Index

await client.ft.create('idx:user', {
  '$.name': { type: 'TEXT', AS: 'name' },
  '$.age': { type: 'NUMERIC', AS: 'age' },
});

Query

const results = await client.ft.search('idx:user', '@name:Alice');
console.log(results.documents);

Example: Search + Filter

await client.ft.search('idx:user', '@name:Ali* @age:[25 40]');

You can also do autocompletion and fuzzy search.

3. RedisTimeSeries – Real-Time Metrics

Ideal for IoT, analytics, and monitoring dashboards.

Create and Insert Time Series

await client.ts.create('temperature:room1', {
  labels: { room: '1', type: 'temp' }
});

await client.ts.add('temperature:room1', Date.now(), 22.5);

Range Query

const range = await client.ts.range('temperature:room1', '-', '+');
console.log(range); // [[timestamp, value], ...]

Downsampling (avg per 1min)

await client.ts.createRule('temperature:room1', 'temperature:avg:1min', {
  aggregation: { type: 'avg', timeBucket: 60000 }
});

Use case: semantic search, image similarity, recommendation engines.

Create Vector Index (HNSW algorithm)

await client.ft.create('idx:embedding', {
  'embedding': {
    type: 'VECTOR',
    ALGORITHM: 'HNSW',
    TYPE: 'FLOAT32',
    DIM: 1536,
    DISTANCE_METRIC: 'COSINE'
  }
});

Add a Document

const vector = Buffer.from(new Float32Array(1536)).toString('base64');

await client.hSet('doc:123', {
  embedding: vector,
  label: 'Product A'
});

Query Similar Vectors

await client.ft.search('idx:embedding', '*=>[KNN 3 @embedding $BLOB]', {
  PARAMS: ['BLOB', vector],
  DIALECT: 2
});

5. RedisGraph – Graph Database in Redis

Model relationships with Cypher query language.

Create Graph

await client.graph.query('social', `
  CREATE (:Person {name: 'John'})-[:FRIEND]->(:Person {name: 'Jane'})
`);

Query Graph

const result = await client.graph.query('social', `
  MATCH (p:Person)-[:FRIEND]->(f:Person)
  RETURN p.name, f.name
`);

Use cases: social networks, fraud detection, network traversal.

6.RedisBloom – Probabilistic Structures

Great for memory-efficient checks and estimates.

Bloom Filter Example

await client.bf.reserve('emails', 0.01, 1000);
await client.bf.add('emails', 'a@b.com');

const exists = await client.bf.exists('emails', 'a@b.com');
console.log(exists); // true

Other structures:

  • Cuckoo filters
  • Count-min sketch
  • Top-K

Real-World Use Cases

Use Case Modules Used
Product search & filtering RedisJSON + RediSearch
IoT data pipeline RedisTimeSeries
Personalized recommendations RedisVector + RedisJSON
Social graph / relationships RedisGraph
Duplicate user check RedisBloom
Real-time analytics dashboard RedisTimeSeries + RediSearch
AI embedding-based search RedisVector

Tools & Libraries

  • @redis/client: Official low-level client
  • Redis OM: High-level ODM for Redis Stack (Node, Python, .NET)
  • Redis Cloud: Managed hosting with Stack features
  • RedisInsight: Admin & query UI

Summary

Redis Stack makes Redis more than just a cache — it’s now:

  • A document store (JSON)
  • A search engine (RediSearch)
  • A time-series DB (RedisTimeSeries)
  • A graph DB (RedisGraph)
  • An AI vector DB (RedisVector)