From 9313e613127b51f2e602a7daa781b738f426a22e Mon Sep 17 00:00:00 2001 From: Jason Mulligan Date: Fri, 29 Sep 2023 08:42:01 -0400 Subject: [PATCH] Updating README.md --- README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 65e825e..f4e60a7 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,31 @@ Least Recently Used cache for Client or Server. +## Using the factory + ```javascript import {lru} from "tiny-lru"; const cache = lru(max, ttl = 0, resetTtl = false); ``` +## Using the Class + +```javascript +import {LRU} from "tiny-lru"; +const cache = new LRU(max, ttl = 0, resetTtl = false); +``` + +```javascript +import {LRU} from "tiny-lru"; +class myCache extends LRU {} +``` + +## Interoperability + Lodash provides a `memoize` function with a cache that can be swapped out as long as it implements the right interface. See the [lodash docs](https://lodash.com/docs#memoize) for more on `memoize`. -## Example +### Example ```javascript _.memoize.Cache = lru().constructor; const memoized = _.memoize(myFunc);