# egg-catbox

> Catbox plugin for eggjs

Latest version **2.0.0** (published 2017-12-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install egg-catbox
pnpm add egg-catbox
yarn add egg-catbox
bun add egg-catbox
```

## 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 | 2.0.0 |
| Published | 2017-12-09 |
| First published | 2017-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | wsw0108 |
| Maintainers | wsw0108 |
| Keywords | egg, eggPlugin, egg-plugin, catbox, cache |

## Links

- npm: https://www.npmjs.com/package/egg-catbox
- Repository: https://github.com/wsw0108/egg-catbox
- Homepage: https://github.com/wsw0108/egg-catbox#readme
- Issues: https://github.com/wsw0108/egg-catbox/issues
- npm.io page: https://npm.io/package/egg-catbox

## Dependencies (2)

- [catbox](https://npm.io/package/catbox.md) ^10.0.2
- [catbox-memory](https://npm.io/package/catbox-memory.md) ^3.1.1

## 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

- 2.0.0 (latest) — 2017-12-09
- 1.0.1 — 2017-04-18

## README

# egg-catbox

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![David deps][david-image]][david-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![npm download][download-image]][download-url]

[npm-image]: https://img.shields.io/npm/v/egg-catbox.svg?style=flat-square
[npm-url]: https://npmjs.org/package/egg-catbox
[travis-image]: https://img.shields.io/travis/wsw0108/egg-catbox.svg?style=flat-square
[travis-url]: https://travis-ci.org/wsw0108/egg-catbox
[codecov-image]: https://img.shields.io/codecov/c/github/wsw0108/egg-catbox.svg?style=flat-square
[codecov-url]: https://codecov.io/github/wsw0108/egg-catbox?branch=master
[david-image]: https://img.shields.io/david/wsw0108/egg-catbox.svg?style=flat-square
[david-url]: https://david-dm.org/wsw0108/egg-catbox
[snyk-image]: https://snyk.io/test/npm/egg-catbox/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/egg-catbox
[download-image]: https://img.shields.io/npm/dm/egg-catbox.svg?style=flat-square
[download-url]: https://npmjs.org/package/egg-catbox

[Catbox](https://github.com/hapijs/catbox) plugin for egg framework.

## Install

```bash
$ npm i egg-catbox --save
```

## Usage

```js
// {app_root}/config/plugin.js
exports.catbox = {
  enable: true,
  package: 'egg-catbox',
};
```

## Configuration

```js
// {app_root}/config/config.default.js
exports.catbox = {
};
```

see [config/config.default.js](config/config.default.js) for more detail.

## Example

```js
// {app_root}/app/service/user.js
const Service = require('egg').Service;

const segment = 'segment';

class UserService extends Service {
  async save(user, ttl) {
    const id = 'id';
    const key = { id, segment };
    await app.catbox.set(key, user, ttl);
  }
  async load(id) {
    const key = { id, segment };
    const result = await app.catbox.get(key);
    return result ? result.item : null;
  }
  async drop(id) {
    const key = { id, segment };
    await app.catbox.drop(key);
  }
}

module.exports = UserService;
```

## Questions & Suggestions

Please open an issue [here](https://github.com/wsw0108/egg-catbox/issues).

## License

[MIT](LICENSE)

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