swarthy/redis-semaphore

View on GitHub
src/redlockSemaphore/release.ts

Summary

Maintainability
A
0 mins
Test Coverage
import createDebug from 'debug'
import type { RedisClient } from '../types'

const debug = createDebug('redis-semaphore:redlock-mutex:release')

export async function releaseRedlockSemaphore(
  clients: RedisClient[],
  key: string,
  identifier: string
) {
  debug(key, identifier)
  const promises = clients.map(client =>
    client.zrem(key, identifier).catch(() => 0)
  )
  const results = await Promise.all(promises)
  debug('results', results)
}