# nx-cache

> Minimal in-memory cache SDK for Node.js

Latest version **1.0.2** (published 2026-01-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install nx-cache
pnpm add nx-cache
yarn add nx-cache
bun add nx-cache
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2026-01-08 |
| First published | 2025-12-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | nx-morpheus |
| Keywords | cache, memory, ttl, typescript |

## Links

- npm: https://www.npmjs.com/package/nx-cache
- Repository: https://github.com/nx-intelligence/nx-cache
- Homepage: https://github.com/nx-intelligence/nx-cache#readme
- Issues: https://github.com/nx-intelligence/nx-cache/issues
- npm.io page: https://npm.io/package/nx-cache

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2026-01-08
- 1.0.1 — 2026-01-08
- 1.0.0 — 2025-12-25

## README

# nx-cache

Minimal in-memory cache SDK for Node.js.

No setup. No config. Just use it.

---

## Install

```bash
npm i nx-cache
```

---

## Usage

```ts
import { createNxCache } from "nx-cache";

const cache = createNxCache();
```

---

## Write

```ts
cache.write(
  "policy",
  { allow: true },
  {
    scope: { orgId: "acme", env: "prod" },
    metadata: { source: "api" },
  }
);
```

* Same key + different scope = different entry
* Scope can be `null`

---

## Read

```ts
const res = cache.read("policy", { orgId: "acme", env: "prod" });

if (res.found) {
  console.log(res.value);
  console.log(res.metadata);
  console.log(res.meta.savedAt);
}
```

Without scope:

```ts
cache.read("policy"); // equivalent to scope = null
```

---

## Search

```ts
const results = cache.search("policy", { orgId: "acme", env: "prod" });

for (const r of results) {
  console.log(r.value, r.metadata);
}
```

---

## Reset

```ts
cache.resetKey("policy", { orgId: "acme", env: "prod" });
cache.resetAll();
```

---

## Behavior summary

* Default TTL: **1 year**
* Expired entries are treated as not found
* Metadata is user-defined and returned on read/search
* Cache is per-process (memory only)

---

## Future extensions (not in v1)

* Redis backend
* Disk persistence
* Stale reads
* Namespaced caches

---
_Source: https://npm.io/package/nx-cache · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
