0.2.0 • Published 4 years ago

axios-cache-mongodb v0.2.0

Weekly downloads
22
License
ISC
Repository
github
Last release
4 years ago

axios cache adapter

a simple cache adapter for axios to cache GET requests in mongodb with a TTL index on the collection (the collection will be created with the index if it doesn't already exist)

v0.2.0

the url, data, and params are now SHA256 hashed and you can use the 'lodash/at' syntax to specify additional properties to hash to create a unique hash, such as headers: ['headers.Authorization']

usage

const axios = require('axios');
const createCache = require('axios-cache-mongodb');

// create a mongodb client and connect
...
const db = client.db(/** db name */);

const axiosCached = axios.create({
  adapter: createCache({
    db: db,
    collectionName: 'axios-cache',
    expireAfterSeconds: 3600,
    match: ['headers.Authorization'] // Optional
  })
});

axiosCached.get('https://example.com/query?id=1234');
0.2.0

4 years ago

0.1.5

4 years ago

0.1.2

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago