# koa-simple-redis

> koa session with redis using koa-simple-session

Latest version **1.0.2** (published 2016-11-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install koa-simple-redis
pnpm add koa-simple-redis
yarn add koa-simple-redis
bun add koa-simple-redis
```

## 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.2 |
| Published | 2016-11-24 |
| First published | 2016-05-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Tree Xie |
| Maintainers | tree.xie |
| Keywords | koa, middleware, session, redis |

## Links

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

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^2.3.3
- [redis](https://npm.io/package/redis.md) ^2.6.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.0.2 (latest) — 2016-11-24
- 1.0.1 — 2016-09-29
- 1.0.0 — 2016-09-29
- 0.0.2 — 2016-06-03
- 0.0.1 — 2016-05-31

## README

# koa-simple-redis

[![Build Status](https://travis-ci.org/vicanso/koa-simple-redis.svg?style=flat-square)](https://travis-ci.org/vicanso/koa-simple-redis)
[![Coverage Status](https://img.shields.io/coveralls/vicanso/koa-simple-redis/master.svg?style=flat)](https://coveralls.io/r/vicanso/koa-simple-redis?branch=master)
[![npm](http://img.shields.io/npm/v/koa-simple-redis.svg?style=flat-square)](https://www.npmjs.org/package/koa-simple-redis)
[![Github Releases](https://img.shields.io/npm/dm/koa-simple-redis.svg?style=flat-square)](https://github.com/vicanso/koa-simple-redis)


Redis storage for koa session middleware/cache, based on [koa-redis](https://github.com/koajs/koa-redis).


## Installation

```
$ npm install koa-simple-redis
``` 

## Examples
  
View the [./examples](examples) directory for working examples. 

## API

### Constructor

- `options` [redis](https://www.npmjs.com/package/redis) options

```js
const Redis = require('koa-simple-redis');
const client = new Redis({
  url: 'redis://127.0.0.1:6379/2',
});
```

### set

- `id` data's id

- `data` data for cache

- `ttl` ttl for data, optional

Set data to the redis or with ttl.

```js
const Redis = require('koa-simple-redis');
const client = new Redis({
  url: 'redis://127.0.0.1:6379/2',
});
client.set('vicanso', {
  a: 1
}).then(() => {
  console.info('success');
});
client.set('jenny', {
  a: 1
}, 10 * 1000).then(() => {
  console.info('success');
});
```

### get

- `id` data's id

Get data from redis.

```js
const Redis = require('koa-simple-redis');
const client = new Redis({
  url: 'redis://127.0.0.1:6379/2',
});
client.set('vicanso', {
  a: 1
}).then(() => {
  return client.get('vicanso')
}).then(data => {
  console.info(data);
  console.info('success');
});

```

### destroy

- `id` data's id

Delete data for redis.

```js
const Redis = require('koa-simple-redis');
const client = new Redis({
  url: 'redis://127.0.0.1:6379/2',
});
client.set('vicanso', {
  a: 1
}).then(() => {
  return client.get('vicanso')
}).then(() => {
  console.info('success');
});

```

### ttl

- `id` data's id

- `ttl` the data's ttl

Get/Set the data's ttl

```js
const Redis = require('koa-simple-redis');
const client = new Redis({
  url: 'redis://127.0.0.1:6379/2',
});
client.set('vicanso', {
  a: 1
}, 10 * 1000).then(() => {
  return client.ttl('vicanso')
}).then((ttl) => {
  console.info('success');
  return client.ttl('vicanso', 30 * 1000);
});
```

### quid

Quit to connect reids.

```js
const Redis = require('koa-simple-redis');
const client = new Redis({
  url: 'redis://127.0.0.1:6379/2',
});
client.quit().then(() => {
  console.info('success');
});
```


## License

MIT

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