{"id":45347,"library":"lru.min","title":"lru.min","description":"lru.min is a fast, efficient, and lightweight LRU (Least Recently Used) cache library for JavaScript. Current stable version is 1.1.4. It supports Node.js (>=8), Bun, Deno, and browsers with ES6+. Unlike other LRU caches, it offers high compatibility and performance comparable to popular alternatives. It ships TypeScript types and has a simple API with features like resize, peek, and eviction callbacks. Development is active with regular updates on GitHub.","status":"active","version":"1.1.4","language":"javascript","source_language":"en","source_url":"https://github.com/wellwelwel/lru.min","tags":["javascript","lru","cache","caching","hash","node","nodejs","bun","deno","typescript"],"install":[{"cmd":"npm install lru.min","lang":"bash","label":"npm"},{"cmd":"yarn add lru.min","lang":"bash","label":"yarn"},{"cmd":"pnpm add lru.min","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This is a named export. Default import will not work.","wrong":"import createLRU from 'lru.min'","symbol":"createLRU","correct":"import { createLRU } from 'lru.min'"},{"note":"CommonJS require must destructure the named export.","wrong":"const createLRU = require('lru.min')","symbol":"createLRU (CommonJS)","correct":"const { createLRU } = require('lru.min')"},{"note":"The browser build is in the 'browser' folder, not 'dist'.","wrong":"<script src=\"https://cdn.jsdelivr.net/npm/lru.min@1.x.x/dist/lru.min.js\"></script>","symbol":"Browser script","correct":"<script src=\"https://cdn.jsdelivr.net/npm/lru.min@1.x.x/browser/lru.min.js\"></script>"}],"quickstart":{"code":"import { createLRU } from 'lru.min';\n\nconst max = 2;\nconst onEviction = (key, value) => {\n  console.log(`Key \"${key}\" with value \"${value}\" has been evicted.`);\n};\n\nconst LRU = createLRU({ max, onEviction });\n\nLRU.set('A', 'My Value');\nLRU.set('B', 'Other Value');\nLRU.set('C', 'Another Value');\n\nconsole.log(LRU.get('B'));\nLRU.delete('B');\nconsole.log(LRU.peek('C'));\nLRU.clear();\nconsole.log(LRU.size);","lang":"typescript","description":"Demonstrates creating an LRU cache with max size and eviction callback, setting and getting values, peeking, deleting, and clearing."},"warnings":[{"fix":"Use `onEviction` (with 'i') when creating the cache.","message":"The option `onEviction` is spelled with 'i' not 'o' (not 'onEviction' as in some other libraries).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Avoid using `undefined` as a key; it will not be stored.","message":"Setting a key with `undefined` is silently ignored; no error thrown.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Call `LRU.clear()` instead of `LRU.evict(LRU.size)` to clear all cache.","message":"The method `evict(max)` is slower than `clear()`. Use `clear()` for removing all entries.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.1.4':21 '8':25 'activ':65 'altern':45 'api':54 'browser':29 'bun':26,78 'cach':13,35,73,74 'callback':62 'compar':42 'compat':39 'current':17 'deno':27,79 'develop':63 'effici':6 'es6':31 'evict':61 'fast':5 'featur':56 'github':70 'hash':75 'high':38 'javascript':16,71 'least':10 'librari':14 'lightweight':8 'like':57 'lru':9,34,72 'lru.min':1,2 'node':76 'node.js':24 'nodej':77 'offer':37 'peek':59 'perform':41 'popular':44 'recent':11 'regular':67 'resiz':58 'ship':47 'simpl':53 'stabl':18 'support':23 'type':49 'typescript':48,80 'unlik':32 'updat':68 'use':12 'version':19","created_at":"2026-06-07T12:54:34.416911+00:00","updated_at":"2026-06-07T12:54:34.416911+00:00","problems":[{"fix":"Run `npm install lru.min` and ensure tsconfig.json has `\"moduleResolution\": \"node\"` or `\"nodenext\"`.","cause":"Missing package installation or TypeScript not configured to resolve node modules.","error":"Cannot find module 'lru.min' or its corresponding type declarations."},{"fix":"Change `import createLRU from 'lru.min'` to `import { createLRU } from 'lru.min'`.","cause":"Using default import instead of named import in ES modules.","error":"TypeError: lru_min_1.createLRU is not a function"},{"fix":"Use `import { createLRU } from 'lru.min'` or switch to CommonJS by setting `\"type\": \"commonjs\"` in package.json.","cause":"Using CommonJS `require` in an ES module context.","error":"ReferenceError: require is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/wellwelwel/lru.min#readme","github":"https://github.com/wellwelwel/lru.min","docs":null,"changelog":null,"pypi":null,"npm":"lru.min","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}