# @junaid1460/simple-redis-cache

> Cache function return value in redis

Latest version **1.0.13** (published 2020-02-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @junaid1460/simple-redis-cache
pnpm add @junaid1460/simple-redis-cache
yarn add @junaid1460/simple-redis-cache
bun add @junaid1460/simple-redis-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.0.13 |
| Published | 2020-02-05 |
| First published | 2019-04-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 9.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Junaid |
| Maintainers | junaid1460 |
| Keywords | redis, cache, function-cache |

## Links

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

## Dependencies (2)

- [redis](https://npm.io/package/redis.md) ^2.8.0
- [@types/redis](https://npm.io/package/@types/redis.md) ^2.8.12

## 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.13 (latest) — 2020-02-05
- 1.0.12 — 2019-08-18
- 1.0.11 — 2019-08-17
- 1.0.10 — 2019-08-15
- 1.0.9 — 2019-07-29
- 1.0.8 — 2019-06-20
- 1.0.7 — 2019-06-20
- 1.0.6 — 2019-04-26
- 1.0.5 — 2019-04-26
- 1.0.4 — 2019-04-26
- 1.0.3 — 2019-04-26
- 1.0.2 — 2019-04-26
- 1.0.1 — 2019-04-26
- 1.0.0 — 2019-04-26

## README

## Simple redis cache
<span class="badge-npmversion"><a href="https://www.npmjs.com/package/@junaid1460/simple-redis-cache" title="View this project on NPM"><img src="https://img.shields.io/npm/v/@junaid1460/simple-redis-cache.svg" alt="NPM version" /></a></span>
Cache data easily with a simple wrap.

```shell

npm i @junaid1460/simple-redis-cache
```

### Usage

##### typescript:

``` typescript
import { RedisCache } from "@junaid1460/simple-redis-cache";

const cache = new RedisCache({
    host: "localhost",
});

function myFunc(x: number, y: number) {
    return cache.cached({
        expiresAfter: 10, // seconds
        keys: [x, y], // list of number or string to construct key
        // closure
        func: async () => {
            return x * y;
        },
    });
}

myFunc(1, 2).get().then((e) => console.log(e.hit, e.data));
```

##### Javascript:
```javascript

const redisCache = require('@junaid1460/simple-redis-cache')
const cache = new redisCache.RedisCache({
    host: 'localhost'
})


function myFunc(x, y) {
    return cache.cached({
        expiresAfter: 10, // seconds
        keys: [x, y], // list of number or string to construct key
        // closure
        func: async () => {
            return x * y;
        },
    });
}

myFunc(1, 2).delete().then((e) => console.log());
```

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