From 62e62347203e2f54185af2d2b87cbb72b7efb223 Mon Sep 17 00:00:00 2001 From: Max Wofford Date: Thu, 9 Jan 2025 10:19:17 -0500 Subject: [PATCH] Make redis lock server-only --- lib/redis-lock.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/redis-lock.ts b/lib/redis-lock.ts index dfe1b25e..8d793c92 100644 --- a/lib/redis-lock.ts +++ b/lib/redis-lock.ts @@ -1,10 +1,11 @@ -'use server' +import 'server-only' + import { kv } from '@vercel/kv' import { v4 as uuidv4 } from 'uuid' const LOCK_TIMEOUT = 30 * 1000 // 30 seconds -export async function aquireLock(key: string): Promise { +async function aquireLock(key: string): Promise { const lockKey = `lock:${key}` const lockValue = uuidv4() const acquired = await kv.set(lockKey, lockValue, { @@ -14,7 +15,7 @@ export async function aquireLock(key: string): Promise { return acquired ? lockValue : null } -export async function releaseLock( +async function releaseLock( lockKey: string, lockValue: string, ): Promise {