MCPcopy Index your code
hub / github.com/simstudioai/sim / acquireLock

Function acquireLock

apps/sim/lib/core/config/redis.ts:228–240  ·  view source on GitHub ↗
(
  lockKey: string,
  value: string,
  expirySeconds: number
)

Source from the content-addressed store, hash-verified

226 * deployments without Redis, the idempotency layer prevents duplicate processing.
227 */
228export async function acquireLock(
229 lockKey: string,
230 value: string,
231 expirySeconds: number
232): Promise<boolean> {
233 const redis = getRedisClient()
234 if (!redis) {
235 return true // No-op when Redis unavailable; idempotency layer handles duplicates
236 }
237
238 const result = await redis.set(lockKey, value, 'EX', expirySeconds, 'NX')
239 return result === 'OK'
240}
241
242/**
243 * Release a distributed lock safely.

Callers 9

acquirePendingChatStreamFunction · 0.90
withCascadeLockFunction · 0.90
runWithRedisMutexFunction · 0.90
withLeaderLockFunction · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90

Calls 2

getRedisClientFunction · 0.85
setMethod · 0.65

Tested by

no test coverage detected