From 10e61e169c9400991c2f3c6f43568d15d79adb72 Mon Sep 17 00:00:00 2001 From: Xavi Alfaro Date: Sat, 15 Jun 2024 21:57:37 -0500 Subject: [PATCH] add TTL to generation --- apps/web/actions.ts | 3 +++ apps/web/constants.ts | 2 ++ 2 files changed, 5 insertions(+) diff --git a/apps/web/actions.ts b/apps/web/actions.ts index 1959860..8ef91d3 100644 --- a/apps/web/actions.ts +++ b/apps/web/actions.ts @@ -3,11 +3,14 @@ import { Redis } from '@upstash/redis' import { revalidatePath } from 'next/cache' import { cookies } from 'next/headers' +import { TTL_SECONDS } from '@/constants' export const saveGeneration = async (data: { sqlSchema: string; cmdCode: string }) => { const { cmdCode, sqlSchema } = data const redis = Redis.fromEnv() const res = await redis.set(cmdCode, sqlSchema) + await redis.expire(cmdCode, TTL_SECONDS) + return res } diff --git a/apps/web/constants.ts b/apps/web/constants.ts index 5dfe4e2..7ca27c4 100644 --- a/apps/web/constants.ts +++ b/apps/web/constants.ts @@ -2,3 +2,5 @@ export const APP_URL = process.env.NODE_ENV === 'development' ? 'http://localhost:3000' : 'https://vdbs.vercel.app/' export const TOTAL_GENERATIONS = 1 +// 1 hour +export const TTL_SECONDS = 60 * 60