Skip to content

Commit

Permalink
Updating README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Sep 29, 2023
1 parent e184087 commit 9313e61
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion README.md
Expand Up @@ -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);
Expand Down

0 comments on commit 9313e61

Please sign in to comment.