Loading packages/server/package.json +2 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,8 @@ "lint": "eslint .", "prisma:studio": "prisma studio", "prisma:migrate": "prisma migrate deploy", "prisma:seed:palette": "./tool.sh seed_palette" "prisma:seed:palette": "./tool.sh seed_palette", "tool": "./tool.sh" }, "keywords": [], "author": "", Loading packages/server/src/lib/redis.ts +11 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,17 @@ class _Redis { this.isConnected = true; } async disconnect() { if (!this.isConnected) { Logger.warn("Redis#disconnect called while not connected"); return; } await this.client.disconnect(); Logger.info("Disconnected from Redis"); this.isConnected = false; } async getClient() { if (!this.isConnected) { await this.connect(); Loading packages/server/src/tools/canvas_cache.ts 0 → 100644 +14 −0 Original line number Diff line number Diff line import Canvas from "../lib/Canvas"; import { Redis } from "../lib/redis"; const log = (...data: any) => { // eslint-disable-next-line no-console console.log(...data); }; (async () => { log("Caching pixels from database to Redis..."); await Canvas.pixelsToRedis(); await Redis.disconnect(); log("Cached"); })(); Loading
packages/server/package.json +2 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,8 @@ "lint": "eslint .", "prisma:studio": "prisma studio", "prisma:migrate": "prisma migrate deploy", "prisma:seed:palette": "./tool.sh seed_palette" "prisma:seed:palette": "./tool.sh seed_palette", "tool": "./tool.sh" }, "keywords": [], "author": "", Loading
packages/server/src/lib/redis.ts +11 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,17 @@ class _Redis { this.isConnected = true; } async disconnect() { if (!this.isConnected) { Logger.warn("Redis#disconnect called while not connected"); return; } await this.client.disconnect(); Logger.info("Disconnected from Redis"); this.isConnected = false; } async getClient() { if (!this.isConnected) { await this.connect(); Loading
packages/server/src/tools/canvas_cache.ts 0 → 100644 +14 −0 Original line number Diff line number Diff line import Canvas from "../lib/Canvas"; import { Redis } from "../lib/redis"; const log = (...data: any) => { // eslint-disable-next-line no-console console.log(...data); }; (async () => { log("Caching pixels from database to Redis..."); await Canvas.pixelsToRedis(); await Redis.disconnect(); log("Cached"); })();