# local-lru-cache

> A local cache module

Latest version **1.0.1** (published 2021-08-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install local-lru-cache
pnpm add local-lru-cache
yarn add local-lru-cache
bun add local-lru-cache
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-08-06 |
| First published | 2021-08-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | selenium39 |
| Maintainers | selenium39 |
| Keywords | cache, lru |

## Links

- npm: https://www.npmjs.com/package/local-lru-cache
- Repository: https://github.com/wantao666/local-lru-cache
- Homepage: https://github.com/wantao666/local-lru-cache#readme
- Issues: https://github.com/wantao666/local-lru-cache/issues
- npm.io page: https://npm.io/package/local-lru-cache

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2021-08-06
- 1.0.0 — 2021-08-06

## README

<h1 align="center">Welcome to local-lru-cache 👋</h1>
<p>
  <img alt="Version" src="https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000" />
  <a href="https://github.com/wantao666/local-lru-cache#readme" target="_blank">
    <img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />
  </a>
  <a href="https://github.com/wantao666/local-lru-cache/graphs/commit-activity" target="_blank">
    <img alt="Maintenance" src="https://img.shields.io/badge/Maintained%3F-yes-green.svg" />
  </a>
  <a href="https://github.com/wantao666/local-lru-cache/blob/master/LICENSE" target="_blank">
    <img alt="License: MIT" src="https://img.shields.io/github/license/wantao666/local-lru-cache" />
  </a>
</p>

> A local cache module 

### ✨ [Example](https://github.com/wantao666/local-lru-cache/blob/master/example.js)
```js
const LocalCache = require('local-lru-cache')

// 1.create LocalCache
const localCache = new LocalCache(5)
localCache.set(1, 'a')
localCache.set(2, 'b')
localCache.get(1)         // a
localCache.get(2)         // a,b

// 2.key with expiration time will be delete after expirate (regularly+lazy)
; (async () => {
        localCache.set(3, 'c', 2000)
        await new Promise(resolve => {
            setTimeout(resolve, 2000)
        })
        localCache.get(3)  // null
})()

/**
 * 3. LRU memory elimination strategy
 *    3.1 only eliminate keys without expiration time
 *    3.2 elimination when localCache.size > cache.size+expireCache.size
 * */
localCache.set(3, 'c',2000) // a,b,c
localCache.set(4, 'd')      // a,b,c,d
localCache.set(5, 'e')      // a,b,c,d,e
localCache.set(6, 'f')      // b,c,d,e,f
localCache.set(7,'g')       // c,d,e,f,g
localCache.set(8,'h')       // c,e,f,g,h


```

### 🏠 [Homepage](https://github.com/wantao666/local-lru-cache#readme)

## Install

```sh
npm install
```

## Author

👤 **selenium39**

* Website: https://blog.csdn.net/qq_45453266
* Github: [@wantao666](https://github.com/wantao666)

## 🤝 Contributing

Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](https://github.com/wantao666/local-lru-cache/issues). You can also take a look at the [contributing guide](https://github.com/wantao666/local-lru-cache/blob/master/CONTRIBUTING.md).

## Show your support

Give a ⭐️ if this project helped you!

## 📝 License

Copyright © 2021 [selenium39](https://github.com/wantao666).<br />
This project is [MIT](https://github.com/wantao666/local-lru-cache/blob/master/LICENSE) licensed.

***
_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_

---
_Source: https://npm.io/package/local-lru-cache · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
