Uses Redis to provide a mechanism for distributed mutual exclusion. If you want
to prevent multiple nodes on a network from accessing a resource at the same
time, this is for you. This lock implementation uses a finite but configurable
expiration time.

Unlike most SETNX-based solutions, this uses Redis's Lua functionality. The
result is cleaner code and fewer race conditions. Lock expiration is handled by
the Redis server itself, using the EXPIRE command, thus eliminating the need
for precise time synchronization between your application hosts.

Calling the lock configuration function yields a lock function that will peform the actual locking. The lock configuration function takes one optional configuration argument, an object with any of the following fields:

The lifetime of the lock, in milliseconds. A lock's lifetime begins counting down as soon as the Redis server receives an EXPIRE command from the lock function. Defaults to 1000 milliseconds (one second).

In the event that the lock has been acquired by another process, the lock function can automatically attempt to re-acquire the lock, up to a configurable number of attempts. Defaults to zero (no automatic retries).

A Redis key where the lock will be stored. This is most likely the name of the resource you are trying to lock.

An optional settings object, with overrides to the original lock configuration.

A callback that takes two arguments:

An error object. This is null if the lock attempt was successful.

A release function, to be called in your application code after the critical section has completed. This will cause the lock to be released. Since the release function is itself asynchronous, you can pass it a callback that will be invoked when the release has been confirmed.