...
This commit is contained in:
parent
9297af6bc3
commit
c0a392c23d
@ -5,6 +5,8 @@ const { query_game, query_guild } = require("../lib/db");
|
|||||||
|
|
||||||
const config = pomelo.app.get("redis");
|
const config = pomelo.app.get("redis");
|
||||||
|
|
||||||
|
const userCacheExpire = 60 * 10;
|
||||||
|
|
||||||
const client = redis.createClient({
|
const client = redis.createClient({
|
||||||
url: `redis://${config.host}:${config.port}/${config.db}`,
|
url: `redis://${config.host}:${config.port}/${config.db}`,
|
||||||
});
|
});
|
||||||
@ -25,6 +27,7 @@ class UserDao {
|
|||||||
const userInfo = JSON.parse(cacheResult);
|
const userInfo = JSON.parse(cacheResult);
|
||||||
userInfo.name = name;
|
userInfo.name = name;
|
||||||
await client.hSet(`t_user:${uid}`, "value", JSON.stringify(userInfo));
|
await client.hSet(`t_user:${uid}`, "value", JSON.stringify(userInfo));
|
||||||
|
await client.expire(`t_user:${uid}`, userCacheExpire);
|
||||||
return userInfo;
|
return userInfo;
|
||||||
} else {
|
} else {
|
||||||
return await this.fetchAndCacheUserInfoFromGameDB(uid);
|
return await this.fetchAndCacheUserInfoFromGameDB(uid);
|
||||||
@ -54,7 +57,8 @@ class UserDao {
|
|||||||
const r = await query_guild(query_insert, [uid, userInfo.name, ""]);
|
const r = await query_guild(query_insert, [uid, userInfo.name, ""]);
|
||||||
|
|
||||||
await client.hSet(`t_user:${uid}`, "value", JSON.stringify(userInfo));
|
await client.hSet(`t_user:${uid}`, "value", JSON.stringify(userInfo));
|
||||||
|
await client.expire(`t_user:${uid}`, userCacheExpire);
|
||||||
|
|
||||||
return userInfo;
|
return userInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user