2.0.0 • Published 2 years ago

@fatcherjs/middleware-cache v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@fatcherjs/middleware-cache

A middleware for caching response result.

codecov install size

Install

NPM

>$ npm install @fatcherjs/middleware-cache

CDN

<script src="https://cdn.jsdelivr.net/npm/@fatcherjs/middleware-cache/dist/cache.min.js"></script>

Usage

import { cache } from '@fatcherjs/middleware-cache';
import { fatcher } from 'fatcher';

fatcher({
    url: '/bar/foo',
    middlewares: [cache({ ttl: 5 * 60 * 1000 })],
    payload: {
        bar: 'foo',
    },
})
    .then(res => {
        console.log(res);
    })
    .catch(err => {
        console.error(error);
    });

Options

NameDescriptionsTypeDefaultValue
useCacheWhether use cachebooleantrue
ttlTime to live(ms)number60 * 1000
validateValidate a request whether needs cache(Context) => booleancontext => context.method === 'GET'

License

LICENSE

1.7.2

2 years ago

1.8.0

2 years ago

2.0.0

2 years ago

1.7.1

2 years ago

1.7.0

2 years ago

1.6.1

2 years ago

1.6.0

2 years ago

1.5.0

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago