Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tinyhttp/lru-send
⏩ LRU-based caching middleware for Node.js
https://github.com/tinyhttp/lru-send
caching http lru memo memoization nodejs performance tinyhttp
Last synced: about 1 month ago
JSON representation
⏩ LRU-based caching middleware for Node.js
- Host: GitHub
- URL: https://github.com/tinyhttp/lru-send
- Owner: tinyhttp
- Created: 2021-06-29T13:05:57.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-09-27T09:17:06.000Z (3 months ago)
- Last Synced: 2024-10-02T07:59:56.312Z (2 months ago)
- Topics: caching, http, lru, memo, memoization, nodejs, performance, tinyhttp
- Language: TypeScript
- Homepage:
- Size: 434 KB
- Stars: 10
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
- awesome-made-by-indonesian - LRU-SEND - `LRU-based caching middleware for Node.js` *by [tinyhttp](https://github.com/tinyhttp)* (L)
- awesome-node-esm - lru-send - LRU-based caching middleware for Node.js (Packages / Middleware)
- made-in-indonesia - LRU-SEND - `LRU-based caching middleware for Node.js` *by [tinyhttp](https://github.com/tinyhttp)* (L)
README
# lru-send
[![npm][npm-img]][npm-url] [![GitHub Workflow Status][actions-badge]][github-actions] [![Coverage][cov-img]][cov-url]
LRU-based caching middleware for Node.js that patches `res.send`.
## Features
- 😲 [**~336x faster**](bench) for heavy operations
- ⚡ ESM-only
- ✨ types out of the box
- 🟥 (optionally) supports [Redis](http://redis.io/)## Install
```sh
pnpm i lru-send
```## Examples
### In-memory
```ts
import { lruSend } from 'lru-send'
import { App } from '@tinyhttp/app'const app = new App()
app.use(lruSend())
app.use('/', (_req, res) => {
someUltraHeavyOp()
res.send('hello')
})app.listen(3000)
```### Redis
```ts
import { lruSend } from 'lru-send/redis'
import { App } from '@tinyhttp/app'
import Redis from 'ioredis'const redis = new Redis()
const app = new App()
app.use(lruSend(redis))
app.use('/', (_req, res) => {
someUltraHeavyOp()
res.send('hello')
})app.listen(3000)
```[npm-url]: https://npmjs.com/package/lru-send
[github-actions]: https://github.com/tinyhttp/lru-send/actions
[cov-img]: https://img.shields.io/coveralls/github/tinyhttp/lru-send?style=for-the-badge&color=9F5E8C
[cov-url]: https://coveralls.io/github/tinyhttp/lru-send
[npm-img]: https://img.shields.io/npm/dt/lru-send?style=for-the-badge&color=9F5E8C
[actions-badge]: https://img.shields.io/github/actions/workflow/status/tinyhttp/lru-send/ci.yml?branch=master&style=for-the-badge&logo=github&label=&color=9F5E8C