# @isekaimaouyoki-sama/fastify-lrucache

> This package is a wrapper for lru-cache

Latest version **1.0.3** (published 2024-03-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install @isekaimaouyoki-sama/fastify-lrucache
pnpm add @isekaimaouyoki-sama/fastify-lrucache
yarn add @isekaimaouyoki-sama/fastify-lrucache
bun add @isekaimaouyoki-sama/fastify-lrucache
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2024-03-29 |
| First published | 2024-03-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 2 |
| Unpacked size | 2.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 0 |
| Maintainers | isekaimaouyoki-sama |
| Keywords | cache, lru-cache, fastify-lrucache |

## Links

- npm: https://www.npmjs.com/package/@isekaimaouyoki-sama/fastify-lrucache
- Repository: https://github.com/isekaimaou1109/fastify-lrucache
- Homepage: https://github.com/isekaimaou1109/fastify-lrucache#readme
- Issues: https://github.com/isekaimaou1109/fastify-lrucache/issues
- npm.io page: https://npm.io/package/@isekaimaouyoki-sama/fastify-lrucache

## Dependencies (2)

- [lru-cache](https://npm.io/package/lru-cache.md) ^10.2.0
- [fastify-plugin](https://npm.io/package/fastify-plugin.md) ^4.5.1

## 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.3 (latest) — 2024-03-29
- 1.0.2 — 2024-03-29

## README

# @isekaimaouyoki-sama/fastify-lrucache

This is a small wrapper around [lru-cache](https://www.npmjs.com/package/lru-cache).

## Install
```
npm install --save @isekaimaouyoki-sama/fastify-lrucache
```

## Usage

Easy to use require/import this plugin as below

```js
const path = require('path')
const fastify = require('fastify')()

fastify.register(
  require('@isekaimaouyoki-sama/fastify-lrucache'),
  { 
    ttl: 1000 * 60 * 5, // 5 minutes
    allowStale: false,  // disable stale data
    ////////////////////// other options. You can see others in lru-cache options
  }
)

fastify.get("/", async function(request, reply) {
  fastify.cacher.set("a", 1)

  if (fastify.cacher.get('a') && +fastify.cacher.get('a') === 1) {
    reply.send("Valid data") 
  } else {
    reply.send("Invalid data") 
  } 
})

fastify.listen({ port: 3000 }, err => {
  if (err) throw err
})
```

---
_Source: https://npm.io/package/@isekaimaouyoki-sama/fastify-lrucache · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
