egg-codis
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

egg-codis

node-codis for egg.

中文说明

Install

$ npm i egg-codis --save

Usage

enable plugin

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

Configuration

// {app_root}/config/config.default.js
exports.codis = {
  zkServers: '127.0.0.1:6701',
  zkCodisProxyDir: '/zk/codis/db_test_node/proxy',
  codisPassword: 'your codis password',
  loadBalancing: true // Whether to enable load balancing
};

See https://github.com/wefront/node-codis#constructor for more detail.

When loadBalancing is true, Inside the egg framework, the plugin will randomly select the codis client for data access.

After the plugin is initialized, you can use app.codis to perform database operations at the application layer.

example

// {app_root}/app/service/user.ts
import { Service } from 'egg'

export default class UserService extends Service {
  public getUserInfo (username: string) {
    this.app.codis.GET(username, function (err, data) {
      return data
    })
  }
}

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.2.2
    2
    • latest

Version History

Package Sidebar

Install

npm i egg-codis

Weekly Downloads

2

Version

1.2.2

License

MIT

Unpacked Size

94.4 kB

Total Files

32

Last publish

Collaborators

  • lavyun