UNPKG

flightworker-atk-auth

Version:

## 中间件部署

33 lines (31 loc) 672 B
'use strict' const Redis = require('@tuniu/node-redis') const co = require('co') const REDIS = Symbol('REDIS') /** * 缓存类 * 配置 * opt - timeout - 默认配置超时 * - ip redis配置ip * - port redis端口 */ module.exports = class { constructor(opt){ this.config = opt this[REDIS] = new Redis(opt.ip, opt.port) } /** * 注册token */ registerToken(key, value){ return this[REDIS].promiseSetex(key, this.config.timeout, value) } /** * 是否注册 * @param key */ *queryRegister(key){ const value = yield this[REDIS].promiseGet(key) return value } }