# @neoskop/redis-promise-cache

> Store promises and synchrone values in redis

Latest version **0.4.2** (published 2022-01-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @neoskop/redis-promise-cache
pnpm add @neoskop/redis-promise-cache
yarn add @neoskop/redis-promise-cache
bun add @neoskop/redis-promise-cache
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.4.2 |
| Published | 2022-01-28 |
| First published | 2019-08-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 43.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Mark Wecke |
| Maintainers | pazulay, jmetzger, mjablonski, hevers, nicolasknop, tlaser, matthias-hampel, draconisnoctis, joshuaga, neotorben, forgrim |
| Keywords | promise, redis, cache, typescript |

## Links

- npm: https://www.npmjs.com/package/@neoskop/redis-promise-cache
- Repository: https://github.com/neoskop/redis-promise-cache
- Homepage: https://github.com/neoskop/redis-promise-cache#readme
- Issues: https://github.com/neoskop/redis-promise-cache/issues
- npm.io page: https://npm.io/package/@neoskop/redis-promise-cache

## 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

- 0.4.2 (latest) — 2022-01-28
- 0.4.1 — 2020-01-07
- 0.4.0 — 2020-01-07
- 0.3.0 — 2019-08-12
- 0.2.0 — 2019-08-08
- 0.1.1 — 2019-08-08
- 0.1.0 — 2019-08-08

## README

# @neoskop/redis-promise-cache  

[![Build](https://travis-ci.org/neoskop/redis-promise-cache.svg?branch=master)](https://travis-ci.org/neoskop/redis-promise-cache)
[![Coverage](https://coveralls.io/repos/github/neoskop/redis-promise-cache/badge.svg?branch=master)](https://coveralls.io/github/neoskop/redis-promise-cache)

Store promises and synchrone values in redis.

Prevents multiple redundant calls to the same (expensive) resource. 
See [here](https://redislabs.com/blog/caches-promises-locks/) for more details.

## Usage

```typescript
import { RedisPromiseCache } from '@neoskop/redis-promise-cache'

const cache = new RedisPromiseCache({ resourceTag: 'db' });
const db : any;

/**
 *  with helper method 
 */
async function getResource(id : string) {
    return cache.getResource(id, () => db.get(id));
}

/**
 *  with "low level" api
 */
async function getResource2(id : string) {
    const cacheEntry = cache.get(id);
    if(cacheEntry) {
        return cacheEntry;
    }

    const promise = db.get(id);
    cache.set(id, promise);

    return promise;
}
```

## Testing

Run tests with `yarn test`. See [package.json](./package.json) for additional test scripts.

## Versioning

This package follows [SemVer](https://semver.org/) and uses [@neoskop/flow-bump](https://github.com/neoskop/flow-bump) for versioning.

## License

This project is licensed under the MIT License - see the [LICENSE.md](./LICENSE.md) file for details

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