LRU-based caching middleware for Node.js
Go to file
v1rtl 1fec98eaaa
Merge pull request #1 from tinyhttp/dependabot/npm_and_yarn/word-wrap-1.2.4
chore(deps-dev): bump word-wrap from 1.2.3 to 1.2.4
2023-10-27 21:12:53 +03:00
.github add github actions and funding 2021-06-29 18:24:26 +03:00
.husky chore: bump husky 2021-07-05 17:55:53 +03:00
bench chore(deps-dev): bump minimist from 1.2.5 to 1.2.8 in /bench 2023-08-03 05:52:07 +00:00
src feat: bump deps and not use default import 2022-03-05 15:34:40 +02:00
tests feat: only cache GET requests and set maxAge to one minute 2021-07-17 16:56:42 +03:00
.eslintrc write the lib 2021-06-29 18:12:26 +03:00
.gitignore chore: release 2021-06-29 18:55:09 +03:00
.prettierignore chore: do not format dist 2021-06-30 12:01:09 +03:00
.prettierrc chore: do not format dist 2021-06-30 12:01:09 +03:00
README.md Update README.md 2023-03-13 20:19:23 +02:00
commitlint.config.cjs tooling: add husky and commitlint 2021-06-29 18:36:07 +03:00
package.json 0.1.3 2022-03-05 15:34:57 +02:00
pnpm-lock.yaml chore(deps-dev): bump word-wrap from 1.2.3 to 1.2.4 2023-07-20 17:44:26 +00:00
rollup.config.js feat: bump deps and not use default import 2022-03-05 15:34:40 +02:00
tsconfig.json feat: bump deps and not use default import 2022-03-05 15:34:40 +02:00

README.md

lru-send

npm GitHub Workflow Status Coverage

LRU-based caching middleware for Node.js that patches res.send.

Features

  • 😲 ~336x faster for heavy operations
  • ESM-only
  • types out of the box
  • 🟥 (optionally) supports Redis

Install

pnpm i lru-send

Examples

In-memory

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

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)