add 活跃统计
This commit is contained in:
3
bin/cache/index.js
vendored
Normal file
3
bin/cache/index.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import NodeCache from "node-cache"
|
||||
export const myCache = new NodeCache({ stdTTL: 3600, checkperiod: 60 });
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import { myCache } from "../cache/index.js";
|
||||
import { client } from "./base.js";
|
||||
|
||||
export async function getRole(guildId){
|
||||
let { data } = await client.roleApi.roles(guildId);
|
||||
return data
|
||||
export async function getRole(guildId) {
|
||||
if(!myCache.get("roleList")){
|
||||
let { data } = await client.roleApi.roles(guildId);
|
||||
myCache.set("roleList",data)
|
||||
return data
|
||||
}else{
|
||||
console.log("缓存命中")
|
||||
return myCache.get("roleList")
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,8 @@ export function query(sql){
|
||||
const c = await connection()
|
||||
c.query(sql,(err,data)=>{
|
||||
if(err){
|
||||
throw new Error("select error")
|
||||
// throw new Error("sql error",err)
|
||||
console.log(err)
|
||||
}else {
|
||||
c.destroy()
|
||||
res(data)
|
||||
|
||||
@@ -19,6 +19,3 @@ export async function isTable(name){
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
console.log(await isTable("aaa"))
|
||||
Reference in New Issue
Block a user