mdast2docx logo Md2Docx
Version 0.1.0

Overview

Updated 22 Oct 2026

CIcodecovnpm versionnpm downloadsnpm bundle sizelicense

@m2d/cache: High-performance, persistent caching engine using xxhash-wasm and IndexedDB for the @m2d ecosystem.

โœจ Features

  • โšก 64-bit Non-Cryptographic Hashing: Uses xxhash-wasm for lightning-fast, collision-resistant cache key generation.
  • ๐Ÿ’พ Multi-Tier Persistence: Supports memory-only, IndexedDB-only, or synchronized hybrid caching.
  • ๐Ÿ›ก๏ธ Poisoned Cache Prevention: Built-in shouldCache predicate prevents caching failed promises, empty buffers, or placeholder errors.
  • ๐Ÿ”€ Parallel Compute & Fetch: Executes cache lookup and generation simultaneously for zero-latency hits.
  • ๐Ÿงน Automatic Cleanup: Time-based LRU-style cleanup using simpleCleanup based on access timestamps.

๐Ÿ“ฆ Installation

$ pnpm add @m2d/cache

or

$ npm install @m2d/cache

or

$ yarn add @m2d/cache

๐Ÿš€ Quick Start

import { createPersistentCache } from "@m2d/cache";

const fetchWithCache = createPersistentCache(
  async (url: string) => {
    const res = await fetch(url);
    return res.json();
  },
  "api-cache",
  { cacheMode: "both" },
);

const data = await fetchWithCache("https://api.example.com/data");

License

This library is licensed under the MIT open-source license.


with ๐Ÿ’– by Mayank Kumar Chaudhari

On this page