# egg-memcache

> memcache plugin of eggjs

Latest version **1.1.4** (published 2017-10-25) · MIT license · 0 weekly downloads

## Install

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

## 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.1.4 |
| Published | 2017-10-25 |
| First published | 2017-10-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | skyfore |
| Maintainers | skyfore |
| Keywords | egg, eggPlugin, egg-plugin, memcached, egg-memcached |

## Links

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

## Dependencies (2)

- [bluebird](https://npm.io/package/bluebird.md) ^3.5.1
- [memcached](https://npm.io/package/memcached.md) ^2.2.2

## 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.1.4 (latest) — 2017-10-25
- 1.1.3 — 2017-10-25
- 1.1.2 — 2017-10-25
- 1.1.1 — 2017-10-25
- 1.1.0 — 2017-10-25
- 1.0.3 — 2017-10-16
- 1.0.2 — 2017-10-16
- 1.0.1 — 2017-10-16
- 1.0.0 — 2017-10-16

## README

# egg-memcache

[![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-memcache.svg?style=flat-square
[npm-url]: https://npmjs.org/package/egg-memcache
[travis-image]: https://img.shields.io/travis/eggjs/egg-memcache.svg?style=flat-square
[travis-url]: https://travis-ci.org/eggjs/egg-memcache
[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-memcache.svg?style=flat-square
[codecov-url]: https://codecov.io/github/eggjs/egg-memcache?branch=master
[david-image]: https://img.shields.io/david/eggjs/egg-memcache.svg?style=flat-square
[david-url]: https://david-dm.org/eggjs/egg-memcache
[snyk-image]: https://snyk.io/test/npm/egg-memcache/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/egg-memcache
[download-image]: https://img.shields.io/npm/dm/egg-memcache.svg?style=flat-square
[download-url]: https://npmjs.org/package/egg-memcache

Memcached plugin of eggjs, Promise wrapped by bluebird. Will start a memcached connection before server start and using in app.

## Install

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

## Usage

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

## Configuration

```js
// {app_root}/config/config.default.js
exports.memcache = {
  url: 'localhost:11211',
  option: {}
};
```
<!--
see [config/config.default.js](config/config.default.js) for more detail.
-->
see [memcached API](https://github.com/3rd-Eden/memcached) for more detail.

## Example

<!-- example here -->
```js
//  {app_root}/service/store.js
module.exports = (app) => {
  const store = {
    set(key, value, lifetime) {
      return app.memcache.setAsync(key, value, lifetime);
    },
    get(key) {
      return app.memcache.getAsync(key);
    }
  }
};

//  {app_root}/controller/index.js
class IndexController extends Controller {
  * setKey() {
    yield this.service.store.set('key', 'value', 0);
  }
  
  * getKey() {
    const key = yield this.service.store.get('key');
  }
}

```

> Also can use native memcache api without `async`, such as `app.memcached.set`

<!--
## Questions & Suggestions
Please open an issue [here](https://github.com/eggjs/egg/issues).
-->

## License

[MIT](LICENSE)

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