# hapi-cacher

> An API caching module for preserving API results for later

Latest version **1.0.2** (published 2018-04-10) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-04-10 |
| First published | 2018-04-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Kino Rose |
| Maintainers | kinoar |
| Keywords | api, cache, hapi-cacher, hapi, cacher, promises, javascript |

## Links

- npm: https://www.npmjs.com/package/hapi-cacher
- Repository: https://github.com/KinoAR/hapi-cacher
- Homepage: https://github.com/KinoAR/hapi-cacher#readme
- Issues: https://github.com/KinoAR/hapi-cacher/issues
- npm.io page: https://npm.io/package/hapi-cacher

## Dependencies (1)

- [moment](https://npm.io/package/moment.md) ^2.22.0

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2018-04-10
- 1.0.1 — 2018-04-10
- 1.0.0 — 2018-04-10

## README

# Hapi Cacher

> A module for caching API requests for a limited time to prevent unnecessary API requests and save you API calls.

## How To Install
```bash
npm install --save hapi-cacher

```

## How To Use

```js
const hapi = require('hapi-cacher');

hapi.get(url, duration); //Returns a promise

//Example
hapi.get('https://api.chucknorris.io/jokes/random', '24hours')
 .then(value => {
   console.log(value);
 });

 //Example 2 - 5 Milliseconds before updating cached value
 hapi.get('https://api.chucknorris.io/jokes/random', '5x')
 .then(value => {
   console.log(value);
 });
```

The duration determines how long before the cached value is updated. Once you set a duration, you can forget about it in future API calls with the same url, and call the function with just the url.

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