3.0.1 • Published 4 months ago

cachette v3.0.1

Weekly downloads
822
License
MIT
Repository
github
Last release
4 months ago

cachette

Resilient cache library supporting concurrent requests through local cache or Redis.

This repo is a work-in-progress and is not ready for general use.

Installation

npm install --save cachette

Basic usage

const { WriteThroughCache } = require('cachette');

// First, initialize the redis connection.
const cache = new WriteThroughCache(process.env.REDIS_URL);

async function fetchUrl(url) {
  console.log('fetching', url);
  const response = await fetch(url);
  console.log('fetched', url);
}

async function fetchUrlCached(url) {
  const fetchFunction = fetchUrl.bind(undefined, url);
  return cache.getOrFetchValue(url, 600, fetchFunction);
}

fetchUrlCached('https://unito.io').then(() => console.log('first call returned'));
// First call fetches the resource, the other calls use the cached value.
fetchUrlCached('https://unito.io').then(() => console.log('second call returned'));
fetchUrlCached('https://unito.io').then(() => console.log('third call returned'));

License

MIT

3.0.1

4 months ago

2.1.9

4 months ago

2.1.8

5 months ago

2.1.6

6 months ago

2.1.7

6 months ago

2.1.5

9 months ago

2.1.4

10 months ago

2.1.3

10 months ago

2.1.2

11 months ago

2.1.1

11 months ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

1.1.44

1 year ago

1.1.43

1 year ago

1.1.41

1 year ago

1.1.42

1 year ago

1.1.40

1 year ago

1.1.39

2 years ago

1.1.34

2 years ago

1.1.33

2 years ago

1.1.32

2 years ago

1.1.31

2 years ago

1.1.38

2 years ago

1.1.37

2 years ago

1.1.36

2 years ago

1.1.35

2 years ago

1.1.30

2 years ago

1.1.29

2 years ago

1.1.28

2 years ago

1.1.27

3 years ago

1.1.26

3 years ago

1.1.25

3 years ago

1.1.23

3 years ago

1.1.22

3 years ago

1.1.24

3 years ago

1.1.21

3 years ago

1.1.20

3 years ago

1.1.19

3 years ago

1.1.18

4 years ago

1.1.17

4 years ago

1.1.16

4 years ago

1.1.13

4 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.5

4 years ago

1.1.4

5 years ago

1.1.1

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago

1.0.0

8 years ago