...
|
...
|
@@ -9,6 +9,7 @@ const keywordsRedis = { |
|
|
'keywordsAllIds': `golobal:yoho:seo:keywords:allIds`,// 关键词表符合条件所有id
|
|
|
'keywordsSortId': `golobal:yoho:seo:keywords:sortId`,// 分类下的所有关键词
|
|
|
'keywordsId': `golobal:yoho:seo:keywords:id`,// 每条关键词关联其它12条关键词
|
|
|
'keywordsIsRun': `golobal:yoho:seo:keywords:isRun`,// 判断是否正在执行中
|
|
|
};
|
|
|
|
|
|
class expandModel extends model {
|
...
|
...
|
@@ -22,12 +23,18 @@ class expandModel extends model { |
|
|
|
|
|
getRanData() {
|
|
|
this.dataIds = [];
|
|
|
|
|
|
return this.mysql.query(`SELECT sort_id FROM seo_keywords WHERE status = 1 GROUP BY sort_id;`).then(rdata => {
|
|
|
return this.redis.setAsync(`${keywordsRedis.keywordsIsRun}`, 1).then(() => {// 设置正在运行的key
|
|
|
return this.redis.expireAsync(`${keywordsRedis.keywordsIsRun}`, 5 * 60);// 设置正在运行的key有效期
|
|
|
}).then(() => {
|
|
|
return this.mysql.query(`SELECT sort_id FROM seo_keywords WHERE status = 1 GROUP BY sort_id;`);
|
|
|
}).then(rdata => {
|
|
|
return Promise.each(rdata, (item) => this._setSortToRedis(item.sort_id));
|
|
|
}).then(d => {
|
|
|
return this.redis.setAsync(`${keywordsRedis.keywordsAllIds}`, JSON.stringify(this.dataIds));
|
|
|
}).then(d => {
|
|
|
|
|
|
this.redis.delAsync(`${keywordsRedis.keywordsIsRun}`);
|
|
|
|
|
|
this.dataIds = [];
|
|
|
return d;
|
|
|
});
|
...
|
...
|
|