# request-cacher

> Cache network request data to avoid repeated requests and improve response time. # Install ```node npm install request-cacher -S ``` # Usage ```javascript import {requestCache} from 'request-cacher' // import axios from 'axios' async function get

Latest version **0.0.2** (published 2021-04-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install request-cacher
pnpm add request-cacher
yarn add request-cacher
bun add request-cacher
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2021-04-27 |
| First published | 2021-04-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | zjfcool |
| Keywords | request-cacher, http, axios, fetch, cache, performance |

## Links

- npm: https://www.npmjs.com/package/request-cacher
- Repository: https://github.com/zjfcool/request-cacher
- Issues: https://github.com/zjfcool/request-cacher/issues
- npm.io page: https://npm.io/package/request-cacher

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.0.2 (latest) — 2021-04-27
- 0.0.1 — 2021-04-23

## README

# Request Cacher
Cache network request data to avoid repeated requests and improve response time.
# Install
```node
npm install request-cacher -S
```
# Usage
```javascript
import {requestCache} from 'request-cacher'
// import axios from 'axios'
async function getData(){
    //oid is unique identification ;data is response data; options is request function arguments;
    //const {oid,data,options} = await requestCache(axios,url)
    const {oid,data,options} = await requestCache(fetch,url,{method:"get"})
    console.log(oid,data)
}
setInterval(()=>{
    getData()//In fact,only one HTTP request occurred
},1000)
```
# API
### requestCache(request,...args)
* request
    * type:function;such as axios,fetch ...
* args
    * is request function option
* return 
    * Promise,and resolve result is a object {oid,data,options,status}
### getCache()
* return cache object
### getCacheByOids(oids)
* oids
    * type:string||number||array, is http request unique identification;
* return
    * oids is string||number return a object
    * oids is array return a array
### clearCache()
After clear cache, http request will be available
## clearCacheByOids(oids)
Clear one or more HTTP request cache
* oids
    * type:string||number||array, is http request unique identification;

---
_Source: https://npm.io/package/request-cacher · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
