# cached-execute

> lock and load

Latest version **1.0.0** (published 2018-05-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install cached-execute
pnpm add cached-execute
yarn add cached-execute
bun add cached-execute
```

## 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.0 |
| Published | 2018-05-25 |
| First published | 2018-05-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 9.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Tuan Anh Tran |
| Maintainers | tuananh |
| Keywords | redis, cache, reload |

## Links

- npm: https://www.npmjs.com/package/cached-execute
- Repository: https://github.com/tuananh/cached-execute
- Issues: https://github.com/tuananh/cached-execute/issues
- npm.io page: https://npm.io/package/cached-execute

## Dependencies (6)

- [ms](https://npm.io/package/ms.md) 2.1.1
- [debug](https://npm.io/package/debug.md) 3.1.0
- [ioredis](https://npm.io/package/ioredis.md) 3.2.2
- [redlock](https://npm.io/package/redlock.md) 3.1.2
- [bluebird](https://npm.io/package/bluebird.md) 3.5.1
- [lodash.isempty](https://npm.io/package/lodash.isempty.md) 4.4.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.0 (latest) — 2018-05-25

## README

# cached-execute

[![npm version](https://badge.fury.io/js/cached-execute.svg)](https://badge.fury.io/js/cached-execute)

> lock and load

Forked of [advanced-cache](https://github.com/HotelQuickly/advanced-cache). For personal use. I plan to gradually add features as I see fit.

## Install

```sh
yarn add cached-execute
# npm install cached-execute
```

## Example

```js
const Promise = require('bluebird')
const { CachedExecute, CachePolicy } = require('./src')

const cache = new CachedExecute({
    host: '127.0.0.1',
    port: 6379,
    keyPrefix: 'test:'
})

// asString example
const policy = new CachePolicy(['item', 1], 60, 30)
function stringPromise() {
    return Promise.delay(100).then(() => 'hello world')
}
cache.asString(policy, stringPromise).then(val => console.log('asString', val))

// asSerialized example
const serializedPolicy = new CachePolicy(['item', 2], '1m', 30)
function objectPromise() {
    return Promise.delay(100).then(() => ({ hello: 'world', foo: 'bar' }))
}
cache.asSerialized(serializedPolicy, objectPromise).then(val => console.log('asSerialized', val))

// asHash example
const hashPolicy = new CachePolicy(['item', 3], 60, 30, ['foo'])
cache.asHash(hashPolicy, objectPromise).then(val => console.log('asHash', val))
```

Output

```
asString hello world
asSerialized { hello: 'world', foo: 'bar' }
asHash { hello: 'world', foo: 'bar' }
```

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