Simple live moves

This commit is contained in:
2026-02-08 16:55:39 +01:00
parent 8f7fc0188c
commit f7401fb319
3 changed files with 29 additions and 10 deletions
+5 -5
View File
@@ -4,6 +4,7 @@ import "server-only";
import { LiveRun, LiveRunMove } from "./types";
import { SupabaseClient } from "@supabase/supabase-js";
import { redis } from "@/lib/redis";
import { randomInt } from "crypto";
/** -------------------- Live Runs in Redis -------------------- */
@@ -55,13 +56,12 @@ export async function addLiveRunMoves(id: string, moves: LiveRunMove[]) {
const pipeline = redis.pipeline();
moves.forEach((move) => {
pipeline.rpush(`liveRunMoves:${id}`, JSON.stringify(move));
setTimeout(() => {
redis.del(`liveRunMoves:${id}`);
}, 3000);
});
// Optional: keep moves ephemeral automatically after 3s
pipeline.expire(`liveRunMoves:${id}`, 3);
setTimeout(() => {
redis.del(`liveRunMoves:${id}`);
}, 3000);
await pipeline.exec();
}