keywords.js
1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
*
* @author: shijian<jian.shi@yoho.cn>
* @date: 17/5/31
*/
'use strict';
const Router = require('koa-router');
const moment = require('moment');
const redisStore = require('koa-redis');
const redis = require("redis");
const client = redis.createClient();
const multi = client.multi();
client.on("error", function (err) {
console.log("Error " + err);
});
const {
OperationLogger
} = require('../../models');
const r = new Router();
const setData = ()=>{
client.set('keywords_mana:aaa', 'aaa');
client.set('keywords_mana:bbb', 'bbb');
let arr = ['keywords_mana:aaa', 'keywords_mana:bbb'];
for (var i=0; i<arr.length; i++) {
multi.sadd('keywords_mana_list', arr[i]);
}
multi.exec(function(errors, results) {
});
}
const getData = async(key)=>{
multi.smembers(key);
return new Promise(function (resolve, reject) {
multi.exec(function(errors, results) {
resolve(results);
});
});
}
r.get('/', async(ctx) => {
await ctx.render('action/keywords');
});
r.get('/getKeywords', async(ctx) => {
let q = ctx.request.query;
let r = await getData("keywords_mana_list");
ctx.body = {
code: 200,
message: 'success',
data: r[0]
};
});
module.exports = r;