https://github.com/karthikeyan-ks/napi-redis
A high-performance Redis abstraction library that implements a normalized cache strategy. By decoupling URL route paths from actual resource data, it eliminates data redundancy and ensures atomic updates across multiple endpoints.[DEVELOPMENT]
https://github.com/karthikeyan-ks/napi-redis
normalization-database redis
Last synced: 29 days ago
JSON representation
A high-performance Redis abstraction library that implements a normalized cache strategy. By decoupling URL route paths from actual resource data, it eliminates data redundancy and ensures atomic updates across multiple endpoints.[DEVELOPMENT]
- Host: GitHub
- URL: https://github.com/karthikeyan-ks/napi-redis
- Owner: karthikeyan-ks
- License: mit
- Created: 2026-03-19T20:39:43.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2026-03-28T16:17:07.000Z (about 2 months ago)
- Last Synced: 2026-03-28T17:53:04.893Z (about 2 months ago)
- Topics: normalization-database, redis
- Language: TypeScript
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# napi-redis [IN DEVELOPEMENT]
A lightweight **normalized data layer on top of Redis** for Node.js.
Think of it as a minimal ORM-like wrapper that brings structure, indexing, and relationships to Redis.
---
## ✨ Why napi-redis?
Redis is fast, but working with raw commands can get messy when your data grows.
`napi-redis` helps you:
* Organize data into **collections (like tables)**
* Store structured data using **hashes**
* Query using **indexes**
* Model simple **relationships**
* Avoid repeated JSON parsing/stringifying
---
## 📦 Installation
```bash
npm install napi-redis
```
---
## 🚀 Quick Start
```js
import NapiRedis from "napi-redis";
const db = new NapiRedis("redis://localhost:6379");
await db.connect();
// insert data
await db.insert("users", {
id: "1",
name: "Karthikeyan",
deptId: "10"
});
// fetch by id
const user = await db.findById("users", "1");
console.log(user);
// query using index
const users = await db.find("users", { name: "Karthikeyan" });
console.log(users);
```
---
## 🧠 Core Concepts
### 1. Collections
Data is grouped into collections (like tables):
```
users:1
users:2
departments:10
```
---
### 2. Hash-based Storage
Each record is stored as a Redis hash:
```
HSET users:1 name "Karthikeyan" deptId "10"
```
---
### 3. Indexing
Indexes are stored using Redis sets:
```
users:index:name:Karthikeyan → [1, 5, 9]
```
This allows fast lookup without scanning all keys.
---
### 4. Relationships
You can store references between collections:
```js
{
id: "1",
name: "Karthikeyan",
deptId: "10"
}
```
Future versions will support automatic relation resolution.
---
## 📚 API (v1)
### `connect()`
Connect to Redis.
### `insert(collection, data)`
Insert a record.
### `findById(collection, id)`
Get a single record by ID.
### `find(collection, query)`
Query records using indexed fields.
---
## ⚙️ Example
```js
await db.insert("departments", {
id: "10",
name: "Computer Science"
});
const dept = await db.findById("departments", "10");
```
---
## 🔥 Roadmap
* [ ] Schema definition
* [ ] Automatic indexing
* [ ] Relationship population (`include`)
* [ ] TTL support
* [ ] In-memory fallback (when Redis is down)
* [ ] TypeScript support
---
## ⚠️ Notes
* This is an early version (v1)
* Not intended as a full replacement for relational databases
* Best suited for caching layers, lightweight data storage, and fast lookups
---
## 🤝 Contributing
Feel free to open issues or submit PRs:
https://github.com/karthikeyan-ks/napi-redis
---
## 📄 License
ISC