# clache

> pooled redis caching made easy

Latest version **0.2.0** (published 2014-07-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install clache
pnpm add clache
yarn add clache
bun add clache
```

## Health

**Score 5/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

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

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2014-07-29 |
| First published | 2014-06-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | Evan Lucas |
| Maintainers | evanlucas |
| Keywords | cache, redis, gaw |

## Links

- npm: https://www.npmjs.com/package/clache
- Repository: https://github.com/GAWMiners/clache
- Issues: https://github.com/GAWMiners/clache/issues
- npm.io page: https://npm.io/package/clache

## Dependencies (3)

- [debug](https://npm.io/package/debug.md) ~1.0.2
- [cache-manager](https://npm.io/package/cache-manager.md) git://github.com/evanlucas/node-cache-manager
- [sol-redis-pool](https://npm.io/package/sol-redis-pool.md) ~0.1.3

## Recent versions

- 0.2.0 (latest) — 2014-07-29
- 0.1.1 — 2014-07-29
- 0.1.0 — 2014-06-26
- 0.0.2 — 2014-06-16
- 0.0.1 — 2014-06-05

## README

# clache
[![Build Status](https://circleci.com/gh/GAWMiners/clache.png?circle-token=130880dd46e2636fb09deca068aac8b183d4fd8e)](https://circleci.com/gh/GAWMiners/clache)
[![Coverage Status](https://coveralls.io/repos/GAWMiners/clache/badge.png?branch=master)](https://coveralls.io/r/GAWMiners/clache?branch=master)

### Author
Evan Lucas

### License
MIT

## Installation
```bash
$ npm install --save clache
```

## Tests
```bash
$ npm test
```

## Coverage
```bash
$ npm run cover
```

## API

### clache()

Contructor

Example

```js
var opts = {
  ttl: 100 // in seconds
, host: '127.0.0.1'
, port: 6379
, password: null
}
var cache = new clache(opts)
```

##### Params
| Name | Type(s) | Description |
| ---- | ------- | ----------- |
| opts | Object | The options object |


***

### clache.wrap()

Wrap an asynchronous function and cache it

Example

```js
function find(cb) {
  return cb(null, { id: 1, name: 'evan' })
}

var id = '1234'
clache.wrap('user_'+id, find, function(err, results) {
  if (err) throw err
  console.log(results)
})
```

##### Params
| Name | Type(s) | Description |
| ---- | ------- | ----------- |
| key | String | The key |
| work | Function | The work function |
| cb | Function | function(err, res) |


***

### clache.set()

Set _val_ for the given _key_

##### Params
| Name | Type(s) | Description |
| ---- | ------- | ----------- |
| key | String | The key |
| val | String, Number, Boolean, Array, Object | The value |
| cb | Function | function(err, res) |


***

### clache.setex()

Set _val_ for the given _key_ with _ttl_

##### Params
| Name | Type(s) | Description |
| ---- | ------- | ----------- |
| key | String | The key |
| ttl | Number | The ttl |
| val | String, Number, Boolean, Array, Object | The value |
| cb | Function | function(err, res) |


***

### clache.get()

Get the value for the given _key_

##### Params
| Name | Type(s) | Description |
| ---- | ------- | ----------- |
| key | String | The key |
| cb | Function | function(err, res) |


***

### clache.del()

Deletes the value for the given _key_

##### Params
| Name | Type(s) | Description |
| ---- | ------- | ----------- |
| key | String | The key |
| cb | Function | function(err, res) |


***

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