优化 排行榜使用redis缓存

This commit is contained in:
luying
2020-11-20 19:47:13 +08:00
parent d51a7119af
commit 1145d95889
6 changed files with 188 additions and 28 deletions
+2 -12
View File
@@ -8,7 +8,7 @@ import {
RouteRecord
} from 'pinus';
import * as mongoose from 'mongoose';
import * as redis from 'redis';
import * as redisService from './app/services/redisService';
import './app/servers/user.rpc.define'
import * as routeUtil from './app/util/routeUtil';
import { preload } from './preload';
@@ -55,17 +55,7 @@ mongoose.connect(mongoAddr, { useNewUrlParser: true, useUnifiedTopology: true },
}
});
// 创建 redis 连接
const client = redis.createClient(6379, redisArr, {detect_buffers: true});
client.auth('zyz_2020', (err, reply) => {
if (err) {
console.log('redis err', err);
} else {
console.log('redis suc');
}
})
client.set('hello', 'redis', redis.print);
redisService.initRank();
/**
* Init app for client.
*/