# @extra-memoize/memory-cache

> ```sh npm install --save @extra-memoize/memory-cache # or yarn add @extra-memoize/memory-cache ```

Latest version **0.3.1** (published 2026-02-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @extra-memoize/memory-cache
pnpm add @extra-memoize/memory-cache
yarn add @extra-memoize/memory-cache
bun add @extra-memoize/memory-cache
```

## Health

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

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

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2026-02-12 |
| First published | 2022-04-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 2 |
| Unpacked size | 41.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | BlackGlory |
| Maintainers | black_glory |

## Links

- npm: https://www.npmjs.com/package/@extra-memoize/memory-cache
- Repository: https://github.com/extra-memoize/memory-cache
- Homepage: https://github.com/extra-memoize/memory-cache#readme
- Issues: https://github.com/extra-memoize/memory-cache/issues
- npm.io page: https://npm.io/package/@extra-memoize/memory-cache

## Dependencies (2)

- [@blackglory/prelude](https://npm.io/package/@blackglory/prelude.md) ^0.4.0
- [@blackglory/structures](https://npm.io/package/@blackglory/structures.md) ^0.14.10

## Recent versions

- 0.3.1 (latest) — 2026-02-12
- 0.3.0 — 2025-07-04
- 0.2.11 — 2025-05-25
- 0.2.10 — 2023-07-24
- 0.2.9 — 2023-06-11
- 0.2.8 — 2023-01-28
- 0.2.7 — 2023-01-28
- 0.2.6 — 2023-01-21
- 0.2.5 — 2022-11-03
- 0.2.4 — 2022-09-09
- 0.2.3 — 2022-08-06
- 0.2.2 — 2022-08-04
- 0.2.1 — 2022-06-26
- 0.2.0 — 2022-05-10
- 0.1.0 — 2022-04-08

## README

# @extra-memoize/memory-cache
## Install
```sh
npm install --save @extra-memoize/memory-cache
# or
yarn add @extra-memoize/memory-cache
```

## API
### Cache
```ts
class Cache<T> implements ICache<T> {
  clear(): void
}
```

### LRUCache
```ts
class LRUCache<T> implements ICache<T> {
  constructor(limit: number)

  delete(key: string): void
  clear(): void
}
```

The classic LRU cache.

### ExpirableCache
```ts
class ExpirableCache<T> implements ICache<T> {
  constructor(timeToLive: number /*ms*/)

  clear(): void
}
```

The classisc expirable cache.

#### ExpirableCacheWithStaleWhileRevalidate
```ts
class ExpirableCacheWithStaleWhileRevalidate<T> implements IStaleWhileRevalidateCache<T> {
  constructor(timeToLive: number /*ms*/, staleWhileRevalidate: number /*ms*/)
}
```

#### ExpirableCacheWithStaleIfError
```ts
class ExpirableCacheWithStaleIfError<T> implements IStaleIfErrorCache<T> {
  constructor(timeToLive: number /*ms*/, staleIfError: number /*ms*/)
}
```

#### ExpirableCacheWithStaleWhileRevalidateAndStaleIfError
```ts
class ExpirableCacheWithStaleWhileRevalidateAndStaleIfError<T> implements IStaleWhileRevalidateAndStaleIfErrorCache<T> {
  constructor(
    timeToLive: number /*ms*/
  , staleWhileRevalidate: number /*ms*/
  , staleIfError: number /*ms*/
  )
}
```

### TLRUCache
```ts
class TLRUCache<T> implements ICache<T> {
  constructor(limit: number, timeToLive: number /*ms*/)

  clear(): void
}
```

The classic TLRU cache.

#### TLRUCacheWithStaleWhileRevalidate
```ts
class TLRUCacheWithStaleWhileRevalidate<T> implements IStaleWhileRevalidateCache<T> {
  constructor(limit: number, timeToLive: number /*ms*/, staleWhileRevalidate: number /*ms*/)
}
```

#### TLRUCacheWithStaleIfError
```ts
class TLRUCacheWithStaleIfError<T> implements IStaleIfErrorCache<T> {
  constructor(limit: number, timeToLive: number /*ms*/, staleIfError: number /*ms*/)
}
```

#### TLRUCacheWithStaleWhileRevalidateAndStaleIfError
```ts
class TLRUCacheWithStaleWhileRevalidateAndStaleIfError<T> implements IStaleWhileRevalidateAndStaleIfErrorCache<T> {
  constructor(
    limit: number
  , timeToLive: number /*ms*/
  , staleWhileRevalidate: number /*ms*/
  , staleIfError: number /*ms*/
  )
}
```

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