1.1.4 • Published 7 years ago

egg-memcache v1.1.4

Weekly downloads
30
License
MIT
Repository
github
Last release
7 years ago

egg-memcache

NPM version build status Test coverage David deps Known Vulnerabilities npm download

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

Install

$ npm i egg-memcache --save

Usage

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

Configuration

// {app_root}/config/config.default.js
exports.memcache = {
  url: 'localhost:11211',
  option: {}
};

see memcached API for more detail.

Example

//  {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

License

MIT

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago