# cache-conf

> Simple cache config handling for your app or module

Latest version **0.6.0** (published 2017-09-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install cache-conf
pnpm add cache-conf
yarn add cache-conf
bun add cache-conf
```

## 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.6.0 |
| Published | 2017-09-14 |
| First published | 2016-09-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20 |
| Author | Sam Verschueren |
| Maintainers | samverschueren, sindresorhus |
| Keywords | cache, caching, config, store, app, storage, conf, configuration, settings, preferences, json, data, persist, persistent, save, load, read, write |

## Links

- npm: https://www.npmjs.com/package/cache-conf
- Repository: https://github.com/samverschueren/cache-conf
- Homepage: https://github.com/samverschueren/cache-conf#readme
- Issues: https://github.com/samverschueren/cache-conf/issues
- npm.io page: https://npm.io/package/cache-conf

## Dependencies (2)

- [conf](https://npm.io/package/conf.md) ^1.2.0
- [pkg-up](https://npm.io/package/pkg-up.md) ^1.0.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.6.0 (latest) — 2017-09-14
- 0.5.0 — 2017-01-21
- 0.4.1 — 2017-01-17
- 0.4.0 — 2017-01-17
- 0.3.0 — 2016-10-23
- 0.2.0 — 2016-09-07
- 0.1.0 — 2016-09-06

## README

# cache-conf [![Build Status](https://travis-ci.org/SamVerschueren/cache-conf.svg?branch=master)](https://travis-ci.org/SamVerschueren/cache-conf)

> Simple cache config handling for your app or module

If you don't need caching, you should use [conf](https://github.com/sindresorhus/conf) instead. This module extends that module and abstracts away the caching mechanism.


## Install

```
$ npm install --save cache-conf
```


## Usage

```js
const delay = require('delay');
const CacheConf = require('cache-conf');
const config = new CacheConf();

config.set('unicorn', '🦄', {maxAge: 5000});
console.log(config.get('unicorn'));
//=> '🦄'

// Wait 5 seconds
await delay(5000);

console.log(config.get('unicorn'));
//=> undefined
```


## API

### CacheConf([options])

Returns a new instance.

#### options

Any of the [conf options](https://github.com/sindresorhus/conf#options).

### Instance

An extended [conf](https://github.com/sindresorhus/conf#instance) instance.

#### get(key, [options])

Get an item.

##### options

###### ignoreMaxAge

Type: `boolean`<br>
Default: `false`

Get the item for the `key` provided without taking the `maxAge` of the item into account.

#### set(key, value, [options])

Set an item.

#### set(object, [options])

Set multiple items at once.

##### options

###### maxAge

Type: `number`

Number of milliseconds the cached value is valid.

###### version

Type: `string`

Version number of the data. If the version provided is not the same as the version of the cached data, the data will be invalid.

#### isExpired(key)

Boolean indicating if the cached data is expired.


## Related

- [conf](https://github.com/sindresorhus/conf) - Simple config handling for your app or module
- [observable-conf](https://github.com/SamVerschueren/observable-conf) - Listen for changes in your conf config


## License

MIT © [Sam Verschueren](https://github.com/SamVerschueren)

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