swr-lru-cache
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

swr-lru-cache

A drop in LRU Cache for SWR

swr-lru-cache is a Least Recently Used (LRU) cache implementation for Vercel's SWR (Stale-While-Revalidate) library. It optimizes memory usage by limiting the number of stored items and evicting the least accessed items when capacity is reached.

Installation

In the root of your application add the following:

import { SWRConfig } from 'swr'
import { SwrLruCache } from 'swr-lru-cache';

// ...

function App() {
// ...

  return (
    <SWRConfig value={{ provider: () => new SwrLruCache(250) }}>
      // ...
    </SWRConfig/>
  );
}

Package Sidebar

Install

npm i swr-lru-cache

Weekly Downloads

1

Version

1.0.5

License

MIT

Unpacked Size

12.9 kB

Total Files

7

Last publish

Collaborators

  • dmmulroy