Skip to main content

Introduction

MiftahDB is a fast and lightweight key-value database library.

Features

  • Fast and efficient key-value storage
  • Support for expiration of keys
  • Disk and in-memory database support
  • Synchronous API for better performance and concurrency
  • Built on top of better-sqlite3 for optimal Node.js performance
  • Utilizes bun:sqlite for seamless Bun integration
  • Pattern-based key retrieval
  • Result type handling ( no try-catch blocks )
  • Supports both Bun and Node.js environments

Installation

# With NPM
npm install miftahdb

# With Bun
bun install miftahdb

Usage

// Node runtime
import { MiftahDB } from "miftahdb";

// For Bun runtime
import { MiftahDB } from "miftahdb/bun";

Example Usage

// Create a new disk-based database instance
const db = new MiftahDB("database.db");

// Use the database
db.set("user:1234", { name: "Ahmad Aburob" });
const user = db.get("user:1234");
console.log(user);