# @patagoniantech/redis-helper

> Redis Helper

Latest version **1.2.0** (published 2020-08-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install @patagoniantech/redis-helper
pnpm add @patagoniantech/redis-helper
yarn add @patagoniantech/redis-helper
bun add @patagoniantech/redis-helper
```

## 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.2.0 |
| Published | 2020-08-20 |
| First published | 2020-05-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 45.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Patagonian |
| Maintainers | alucchetti, cubodehelio, jfgabriel, npm-patagoniantech, reduardo7, rodrigofalco |
| Keywords | redis, patagonian, patagoniansys, patagoniantech, helper, tool, cache |

## Links

- npm: https://www.npmjs.com/package/@patagoniantech/redis-helper
- Repository: https://github.com/PatagonianTech/redis-helper
- Homepage: https://github.com/PatagonianTech/redis-helper#readme
- Issues: https://github.com/PatagonianTech/redis-helper/issues
- npm.io page: https://npm.io/package/@patagoniantech/redis-helper

## Dependencies (2)

- [ioredis](https://npm.io/package/ioredis.md) ^4.17.1
- [typescript](https://npm.io/package/typescript.md) ^3.9.3

## 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.2.0 (latest) — 2020-08-20
- 1.1.1 — 2020-05-27
- 1.1.0 — 2020-05-27
- 1.0.3 — 2020-05-27
- 1.0.2 — 2020-05-27
- 1.0.1 — 2020-05-27
- 1.0.0 — 2020-05-26
- 0.1.0 — 2020-05-26

## README

# redis-helper

Redis Helper.

## Usage

### Using RedisHelperConnection

```typescript
import RedisHelperConnection from '@patagoniantech/redis-helper';

const REDIS_HOST = process.env.REDIS_HOST || '127.0.0.1';
const REDIS_PORT = Number(process.env.REDIS_PORT) || 6379;
const REDIS_CACHE_EXPIRE = 5; // in seconds

const connection = new RedisHelperConnection({
  config: {
    host: REDIS_HOST,
    port: REDIS_PORT,
  },
});

const redisHelper = connection.create('test', REDIS_CACHE_EXPIRE);

const a = await redisHelper.tryGet('a', 123);
console.log('Check if a=123', a);

const b = await redisHelper.tryGet('a', 321);
console.log('Check if b=123', b);

const d = await redisHelper.del('a');
console.log('deleted records:', 1);

// Close Redis connection
await connection.close();
```

### Using IO Redis instance

```typescript
import Redis from 'ioredis';
import { RedisHelper } from '@patagoniantech/redis-helper';

const REDIS_HOST = process.env.REDIS_HOST || '127.0.0.1';
const REDIS_PORT = Number(process.env.REDIS_PORT) || 6379;
const REDIS_CACHE_EXPIRE = 5; // in seconds

const connection = new Redis({
  config: {
    host: REDIS_HOST,
    port: REDIS_PORT,
  },
});

const redisHelper = new RedisHelper(connection, 'testPrefix', REDIS_CACHE_EXPIRE);

const a = await redisHelper.tryGet('a', 123);
console.log('Check if a=123', a);

const b = await redisHelper.tryGet('a', 321);
console.log('Check if b=123', b);

const d = await redisHelper.del('a');
console.log('deleted records:', 1);

// Close Redis connection
await connection.close();
```

## Doc

See [docs/index.html](https://htmlpreview.github.io/?https://github.com/PatagonianTech/redis-helper/blob/master/docs/globals.html).

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