{"id":44981,"library":"flru","title":"flru","description":"A tiny (215B) and fast Least Recently Used (LRU) cache for JavaScript. Stable version 1.0.2, last updated in 2019. No active release cadence; essentially stable and minimal. Key differentiators: extremely small size (215B), high performance with a two-cache internal architecture that trades memory for speed, supports ESM, CJS, and UMD formats, and includes TypeScript types. Compared to alternatives like lru-cache or tiny-lru, flru is much smaller and faster for typical operations but uses 2n memory and has a simpler API.","status":"active","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/lukeed/flru","tags":["javascript","lru","cache","lru-cache","mru","typescript"],"install":[{"cmd":"npm install flru","lang":"bash","label":"npm"},{"cmd":"yarn add flru","lang":"bash","label":"yarn"},{"cmd":"pnpm add flru","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export only; named import will not work. CJS: const flru = require('flru').","wrong":"import { flru } from 'flru'","symbol":"flru","correct":"import flru from 'flru'"},{"note":"CJS: flru is the default export, not a named export.","wrong":"const { flru } = require('flru')","symbol":"flru","correct":"const flru = require('flru')"},{"note":"If you use TypeScript, you can import the CacheType interface. It is not required.","wrong":"","symbol":"CacheType","correct":"import type { CacheType } from 'flru'"}],"quickstart":{"code":"import flru from 'flru';\n\nconst cache = flru(3); // max 3 items\ncache.set('a', 1);\ncache.set('b', 2);\ncache.set('c', 3);\ncache.has('a'); // true\ncache.get('a'); // 1\ncache.set('d', 4); // evicts oldest (b)\ncache.get('b'); // undefined\ncache.clear();\ncache.has('a'); // false","lang":"typescript","description":"Creates an LRU cache with max 3 items, demonstrates set, get, has, eviction, and clear."},"warnings":[{"fix":"Consider memory implications when using with large limits.","message":"flru uses two internal caches (active and stale) and stores up to 2n items. Memory usage is roughly double the limit compared to single-cache LRU implementations.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Read the documentation on the two-cache architecture to understand eviction behavior.","message":"get() does NOT promote a key to the active cache if the key is in the stale cache; it returns the value but the key may be evicted later.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always pass a positive integer to flru().","message":"The default max is 1, which is inefficient and likely not what you want. Always specify a max.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Evaluate lru-cache or tiny-lru for active maintenance.","message":"The package appears unmaintained since 2019. No known security issues, but consider alternatives for long-term support.","severity":"deprecated","affected_versions":"1.0.2"}],"env_vars":null,"search_vec":"'1.0.2':16 '2019':20 '215b':4,34 '2n':81 'activ':22 'altern':61 'api':87 'architectur':43 'cach':11,41,65,90,93 'cadenc':24 'cjs':51 'compar':59 'differenti':30 'esm':50 'essenti':25 'extrem':31 'fast':6 'faster':75 'flru':1,70 'format':54 'high':35 'includ':56 'intern':42 'javascript':13,88 'key':29 'last':17 'least':7 'like':62 'lru':10,64,69,89,92 'lru-cach':63,91 'memori':46,82 'minim':28 'mru':94 'much':72 'oper':78 'perform':36 'recent':8 'releas':23 'simpler':86 'size':33 'small':32 'smaller':73 'speed':48 'stabl':14,26 'support':49 'tini':3,68 'tiny-lru':67 'trade':45 'two':40 'two-cach':39 'type':58 'typescript':57,95 'typic':77 'umd':53 'updat':18 'use':9,80 'version':15","created_at":"2026-06-07T12:52:46.762426+00:00","updated_at":"2026-06-07T12:52:46.762426+00:00","problems":[{"fix":"Use import flru from 'flru'","cause":"Trying to import flru as a named export instead of default.","error":"import { flru } from 'flru'"},{"fix":"Use const flru = require('flru')","cause":"CJS destructuring on a default export.","error":"const { flru } = require('flru')"},{"fix":"Call flru with a max number: const cache = flru(3)","cause":"Using flru without calling it, e.g., assigning flru instead of flru(3).","error":"flru is not a function"}],"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/lukeed/flru#readme","github":"https://github.com/lukeed/flru","docs":null,"changelog":null,"pypi":null,"npm":"flru","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}}