Skip to content

Commit

Permalink
add TTL to generation
Browse files Browse the repository at this point in the history
  • Loading branch information
xavimondev committed Jun 16, 2024
1 parent 74af0d9 commit 10e61e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apps/web/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 2 additions & 0 deletions apps/web/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 10e61e1

Please sign in to comment.