I can't be bothered to even explain what happene here

This commit is contained in:
2025-02-07 23:18:04 -05:00
parent d982567c7b
commit bc3443b1dc
21 changed files with 994 additions and 177 deletions

View File

@@ -1,14 +1,13 @@
import { Redis } from "ioredis";
import * as Config from "./config.ts";
import Logging from "@proxnet/undead-logging";
import process from "node:process";
const log = new Logging("RedisDB");
const config = Config.getConfig();
if (typeof config == 'undefined') {
log.e(`Cannot start: Redis configuration failed`);
process.exit(1);
Deno.exit(1);
}
let shuttingDown = false;
@@ -16,18 +15,19 @@ Deno.addSignalListener('SIGINT', () => {
if (shuttingDown) return;
shuttingDown = true;
log.n('Disconnecting from Redis');
if (typeof Database !== 'undefined') Database.quit();
Database.quit();
});
export let Database: Redis | undefined;
export const Database = new Redis({
port: config?.redis.port,
host: config?.redis.host,
username: config?.redis.username == "" ? undefined : config?.redis.username,
password: config?.redis.password == "" ? undefined : config?.redis.password,
db: config?.redis.db,
lazyConnect: true
});
export function connectToRedis() {
Database = new Redis({
port: config?.redis.port,
host: config?.redis.host,
username: config?.redis.username == "" ? undefined : config?.redis.username,
password: config?.redis.password == "" ? undefined : config?.redis.password,
db: config?.redis.db
});
Database.connect();
log.i(`Connected to Redis`);
}
@@ -35,13 +35,18 @@ export function buildKey(...args: string[]) {
return args.join(':');
}
export const KeyGroups = {
Config: {
Root: "config",
Dynamic: "dynamic"
},
Accounts: {
Ids: "account-ids",
Usernames: "account-usernames",
DisplayNames: "account-displaynames",
XP: "account-scores",
Developers: "account-developers",
ProfileImages: "account-images"
Root: "accounts",
Ids: "ids",
Usernames: "usernames",
DisplayNames: "displaynames",
XP: "scores",
Developers: "developers",
ProfileImages: "images"
}
}
export * as Redis from "./db.ts";