0.1.1 • Published 4 years ago

@aniu2017/egg-request-cache v0.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

egg-request-cache

只是代理了Egg内置的curl函数,参数都与curl保持一致

Install

$ npm i @aniu2017/egg-request-cache -S

Usage

// {app_root}/config/plugin.js
exports['request-cache'] = {
  enable: true,
  package: 'egg-request-cache',
};

Configuration

// {app_root}/config/config.default.js
exports.requestCache = {
  expiresTime: '', // 缓存时间 单位毫秒
  redisPrefixKey: 'test', // redis key前缀 可选
};

see config/config.default.js for more detail.

Example

  // {app_root}/Controller/user.js

  // 默认设置了 dataType json method get
  await this.app.requestCache.get('http://127.0.0.1:7001/users');
  // 默认设置了 dataType json method post
  await this.app.requestCache.post('http://127.0.0.1:7001/users', [options]);

  // 没默认值
  await this.app.requestCache('http://127.0.0.1:7001/users', [options]);