{
  "_id": "@alloc/quick-lru",
  "maintainers": [
    {
      "name": "aleclarson",
      "email": "aleclarson@protonmail.com"
    }
  ],
  "keywords": [
    "lru",
    "quick",
    "cache",
    "caching",
    "least",
    "recently",
    "used",
    "fast",
    "map",
    "hash",
    "buffer"
  ],
  "dist-tags": {
    "latest": "5.2.0"
  },
  "author": {
    "name": "Sindre Sorhus",
    "email": "sindresorhus@gmail.com",
    "url": "https://sindresorhus.com"
  },
  "_rev": "1-4115df71993630a5c00b3ae7c9eba338",
  "description": "Simple “Least Recently Used” (LRU) cache",
  "readme": "# quick-lru [![Build Status](https://travis-ci.org/sindresorhus/quick-lru.svg?branch=master)](https://travis-ci.org/sindresorhus/quick-lru) [![Coverage Status](https://coveralls.io/repos/github/sindresorhus/quick-lru/badge.svg?branch=master)](https://coveralls.io/github/sindresorhus/quick-lru?branch=master)\n\n> Simple [“Least Recently Used” (LRU) cache](https://en.m.wikipedia.org/wiki/Cache_replacement_policies#Least_Recently_Used_.28LRU.29)\n\nUseful when you need to cache something and limit memory usage.\n\nInspired by the [`hashlru` algorithm](https://github.com/dominictarr/hashlru#algorithm), but instead uses [`Map`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Map) to support keys of any type, not just strings, and values can be `undefined`.\n\n## Install\n\n```\n$ npm install quick-lru\n```\n\n## Usage\n\n```js\nconst QuickLRU = require('quick-lru');\n\nconst lru = new QuickLRU({maxSize: 1000});\n\nlru.set('🦄', '🌈');\n\nlru.has('🦄');\n//=> true\n\nlru.get('🦄');\n//=> '🌈'\n```\n\n## API\n\n### new QuickLRU(options?)\n\nReturns a new instance.\n\n### options\n\nType: `object`\n\n#### maxSize\n\n*Required*\\\nType: `number`\n\nThe maximum number of items before evicting the least recently used items.\n\n#### maxAge\n\nType: `number`\\\nDefault: `Infinity`\n\nThe maximum number of milliseconds an item should remain in cache.\nBy default maxAge will be Infinity, which means that items will never expire.\n\nLazy expiration happens upon the next `write` or `read` call.\n\nIndividual expiration of an item can be specified by the `set(key, value, options)` method.\n\n#### onEviction\n\n*Optional*\\\nType: `(key, value) => void`\n\nCalled right before an item is evicted from the cache.\n\nUseful for side effects or for items like object URLs that need explicit cleanup (`revokeObjectURL`).\n\n### Instance\n\nThe instance is [`iterable`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Iteration_protocols) so you can use it directly in a [`for…of`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/for...of) loop.\n\nBoth `key` and `value` can be of any type.\n\n#### .set(key, value, options?)\n\nSet an item. Returns the instance.\n\nIndividual expiration of an item can be specified with the `maxAge` option. If not specified, the global `maxAge` value will be used in case it is specified on the constructor, otherwise the item will never expire.\n\n#### .get(key)\n\nGet an item.\n\n#### .has(key)\n\nCheck if an item exists.\n\n#### .peek(key)\n\nGet an item without marking it as recently used.\n\n#### .delete(key)\n\nDelete an item.\n\nReturns `true` if the item is removed or `false` if the item doesn't exist.\n\n#### .clear()\n\nDelete all items.\n\n#### .resize(maxSize)\n\nUpdate the `maxSize`, discarding items as necessary. Insertion order is mostly preserved, though this is not a strong guarantee.\n\nUseful for on-the-fly tuning of cache sizes in live systems.\n\n#### .keys()\n\nIterable for all the keys.\n\n#### .values()\n\nIterable for all the values.\n\n#### .entriesAscending()\n\nIterable for all entries, starting with the oldest (ascending in recency).\n\n#### .entriesDescending()\n\nIterable for all entries, starting with the newest (descending in recency).\n\n#### .size\n\nThe stored item count.\n\n---\n\n<div align=\"center\">\n\t<b>\n\t\t<a href=\"https://tidelift.com/subscription/pkg/npm-quick-lru?utm_source=npm-quick-lru&utm_medium=referral&utm_campaign=readme\">Get professional support for this package with a Tidelift subscription</a>\n\t</b>\n\t<br>\n\t<sub>\n\t\tTidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.\n\t</sub>\n</div>\n",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/sindresorhus/quick-lru.git"
  },
  "bugs": {
    "url": "https://github.com/sindresorhus/quick-lru/issues"
  },
  "license": "MIT",
  "versions": {
    "5.2.0": {
      "name": "@alloc/quick-lru",
      "version": "5.2.0",
      "description": "Simple “Least Recently Used” (LRU) cache",
      "license": "MIT",
      "repository": {
        "type": "git",
        "url": "git+https://github.com/sindresorhus/quick-lru.git"
      },
      "funding": "https://github.com/sponsors/sindresorhus",
      "author": {
        "name": "Sindre Sorhus",
        "email": "sindresorhus@gmail.com",
        "url": "https://sindresorhus.com"
      },
      "engines": {
        "node": ">=10"
      },
      "scripts": {
        "test": "xo && nyc ava && tsd"
      },
      "keywords": [
        "lru",
        "quick",
        "cache",
        "caching",
        "least",
        "recently",
        "used",
        "fast",
        "map",
        "hash",
        "buffer"
      ],
      "devDependencies": {
        "ava": "^2.0.0",
        "coveralls": "^3.0.3",
        "nyc": "^15.0.0",
        "tsd": "^0.11.0",
        "xo": "^0.26.0"
      },
      "gitHead": "73f6da4abbf081e8dd885405bd0a2c645c3a5eed",
      "bugs": {
        "url": "https://github.com/sindresorhus/quick-lru/issues"
      },
      "homepage": "https://github.com/sindresorhus/quick-lru#readme",
      "_id": "@alloc/quick-lru@5.2.0",
      "_nodeVersion": "14.13.1",
      "_npmVersion": "6.14.8",
      "dist": {
        "integrity": "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==",
        "shasum": "7bf68b20c0a350f936915fcae06f58e32007ce30",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/@alloc/quick-lru/-/quick-lru-5.2.0.tgz",
        "fileCount": 5,
        "unpackedSize": 14099,
        "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJga6sjCRA9TVsSAnZWagAA/pEP/0y6cdGEoUIqYYfBiFQ9\nkblkmT9wU9jIFMWnrb4mQSjpFW4CyUgx0dAKnh72Wm0qrObNLdIf/xx7i2L+\nYxKT35Hb3H9N0iEaYswXhU032Soi/QRbRHMeJlupIZd/4yIHB5AyCW+4Bwsx\n9Z1D4Ai9SAlYHb7Uz/IUPWgZf5Bsg1MdL2IVBcwy20fisRlXfQIGIJI6K2N0\nbhCrH7mQF6yG1/5IGCrunO8dcBP8TZ3n0U3k9oGVAu005qPiBuLXT/Cl2w01\nCLKvFTlWCSJrOJh3UyQE3OQebjXwMjJ1ixSiWINt0tqKPpw1gf2JTD3EEa5g\nxJwqmGb1bZc87q+HkruhnCx1B5MCmJmWU9Yby5LeUYRecu6eVFmQC3IWKr/p\ny5TsafBxkDbCCiir11eaNKLeJB5jnHkCk3wog+/ypK7Mpy7gFHSt7ddeKZ1/\nXXw0VrfdlL1oWk/5QWcRdT3JH16IJXJ0fvfVTUq4qe/jYcmduwfgARzJcXrq\nPaaxT+ydyaPZ6BPtHVvzERSA46X+cMtvC34laOydad3ZJj9XOyviu6THsOgl\nqQlv0mEIWKcu87cLh2Z86Di6GsSijp0wU66UG4usm8Pf/clcTCcB5OSRfzgK\niagvWy4eyAKJ1N48jr8B5ol3oYnn9i6lovGuOT1IbW40XYyik5/zCGZFq+G2\nfxOJ\r\n=jseG\r\n-----END PGP SIGNATURE-----\r\n",
        "signatures": [
          {
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
            "sig": "MEUCIAGbPdEPixVJQACokSA1qIsceyVA9O4ya5yo9tFOBHe2AiEA6a7o92d0HLq9FzrUif7JRc9Uaw6NpgEPrSaNwKd/628="
          }
        ]
      },
      "_npmUser": {
        "name": "aleclarson",
        "email": "aleclarson@protonmail.com"
      },
      "directories": {},
      "maintainers": [
        {
          "name": "aleclarson",
          "email": "aleclarson@protonmail.com"
        }
      ],
      "_npmOperationalInternal": {
        "host": "s3://npm-registry-packages",
        "tmp": "tmp/quick-lru_5.2.0_1617668898547_0.8839094547660911"
      },
      "_hasShrinkwrap": false
    }
  },
  "name": "@alloc/quick-lru",
  "time": {
    "created": "2021-04-06T00:28:18.367Z",
    "5.2.0": "2021-04-06T00:28:18.669Z",
    "modified": "2026-05-06T08:25:12.631Z"
  },
  "readmeFilename": "readme.md",
  "homepage": "https://github.com/sindresorhus/quick-lru#readme"
}