Back to Explore

sindresorhus/quick-lru

GitHub
1 watchersOpen source

Last release: 7 months ago

quick-lru is a simple Least Recently Used (LRU) cache for JavaScript that stores key-value pairs up to a configurable max size and evicts the least recently used items when the limit is reached. It’s useful when you need caching with controlled memory usage, with optional maxAge-based expiration and an onEviction callback for cleanup.

Project status

  • Actively maintained, with recent tagged updates and accompanying implementation changes, TypeScript typings, README documentation, and tests (v7.3.0 on 2025-10-10, v7.2.0 on 2025-09-16, v7.1.0 on 2025-08-20).
  • Update cadence appears steady and fairly frequent, roughly every 3 to 4 weeks across the recent v7.1.0 to v7.3.0 updates.

AI summary generated Today

AI-generated from public sources. May be inaccurate. Report

Recent updates

  • v7.3.0

    7 months ago

    v7.3.0 adds a new `.maxAge` getter to expose the configured maximum age value from `QuickLRU`. The update includes corresponding TypeScript typings, README documentation, and new tests validating default and configured behavior.

    Features
  • v7.2.0

    8 months ago

    Release v7.2.0 adds a new `evict()` instance method to QuickLRU for removing the least recently used entries. Alongside the new API, the TypeScript declarations, README documentation, and test suite are updated to describe and verify the new eviction behavior.

    Features
  • v7.1.0

    9 months ago

    v7.1.0 adds a new cache inspection API, `expiresIn(key)`, to report the remaining time-to-live for a given entry. The implementation reads TTL directly from internal cache bookkeeping without triggering lazy eviction.

    Features
  • v7.0.1

    4/9/2025

    v7.0.1 focuses on safer, simpler string/log output for the QuickLRU class instance, especially when values include circular references. The release notes mention a circular-object logging fix and that the logged output was simplified.

  • v7.0.0

    9/11/2023

    v7.0.0 is a major update that raises the minimum supported Node.js version to 18. It also adds a new `.maxSize` getter for the cache. Code changes include a significant internal refactor to use private class fields and updated type declarations.

    BreakingFeatures
  • v6.1.2

    8/27/2023

    v6.1.2 updates quick-lru behavior so the `set()` method returns the cache instance, enabling fluent chaining. The release notes mention a return value fix for `set()`, and the code change matches that.

  • v6.1.1

    3/26/2022

    This release (v6.1.1) updates QuickLRU's handling of Symbol.toStringTag. The release notes describe a fix to internal toStringTag usage, and the code changes show a more significant behavioral adjustment in how the tag value is provided and consumed.

  • v6.1.0

    2/18/2022

    v6.1.0 changes QuickLRU to extend the built-in Map class. In addition to the base class change, the implementation adds Map-compatibility methods so QuickLRU can be used more like a native Map.

    BreakingFeatures
  • v6.0.2

    11/21/2021

    v6.0.2 includes a fix related to how `maxAge` is handled when provided to `quick-lru` via the `set(key, value, {maxAge})` option. The code change adjusts the way per-item expiration is calculated, and the test suite was updated accordingly.

  • v6.0.1

    8/9/2021

    v6.0.1 is a small patch release for quick-lru. It primarily fixes expiration handling when calling set() on an existing key, ensuring the stored entry gets the correct expiry time. The release notes only mention this expiration fix.