1 # 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)
3 > Simple ["Least Recently Used" (LRU) cache](https://en.m.wikipedia.org/wiki/Cache_replacement_policies#Least_Recently_Used_.28LRU.29)
5 Useful when you need to cache something and limit memory usage.
7 Inspired by the [`haslru` 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`.
13 $ npm install quick-lru
20 const QuickLRU = require('quick-lru');
22 const lru = new QuickLRU({maxSize: 1000});
24 lru.set('π¦', 'π');
36 ### new QuickLRU([options])
38 Returns a new instance.
49 Maximum number of items before evicting the least recently used items.
53 The 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.
55 Both `key` and `value` can be of any type.
59 Set an item. Returns the instance.
67 Check if an item exists.
71 Get an item without marking it as recently used.
83 Iterable for all the keys.
87 Iterable for all the values.
96 MIT Β© [Sindre Sorhus](https://sindresorhus.com)