# ephemeral-cache

> Cache with timed expiry of contents

Latest version **1.1.0** (published 2017-01-02) · MIT license · 0 weekly downloads

## Install

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

## 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.1.0 |
| Published | 2017-01-02 |
| First published | 2016-12-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | coinpit |
| Maintainers | bharathrao |
| Keywords | cache, timeout, expiry |

## Links

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

## Dependencies (1)

- [expect.js](https://npm.io/package/expect.js.md) ^0.3.1

## 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.1.0 (latest) — 2017-01-02
- 1.0.2 — 2016-12-30
- 1.0.1 — 2016-12-30
- 1.0.0 — 2016-12-30

## README

# ephemeral-cache
Cache that expires entries with timeout

# Usage

### Instantiate with default 30s timeout
```javascript
var cache = require('ephemeral-cache')
```

### Change timeout to 30 minutes
```javascript
cache.timeout = 30 * 60 * 1000
```

### Main Operations

```javascript

var value0 = cache.get('key') // returns undefined for non-existent keys

cache.put('key', 'value')

var value1 = cache.get('key') // returns 'value'

var value2 = cache.del('key') // returns 'value' if deleted key exists

var value3 = cache.get('key') // returns undefined for deleted keys

var size = cache.size()
```

### Reset to clean state; delete everything

```javascript
cache.reset()
```
### Notes

Timeout does not restart on get operation. Explicitly put again if needed.

```javascript

cache.put('key', 'value')

var value = cache.get('key')

cache.put('key', value) // restart timer
```

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