Files
firecrawl/apps/api/src/services/redlock.ts
T

27 lines
833 B
TypeScript
Raw Normal View History

2024-08-12 13:37:47 -04:00
import Redlock from "redlock";
import Client from "ioredis";
export const redlock = new Redlock(
// You should have one client for each independent redis node
// or cluster.
2024-11-07 20:57:33 +01:00
[new Client(process.env.REDIS_RATE_LIMIT_URL!)],
2024-08-12 13:37:47 -04:00
{
// The expected clock drift; for more details see:
// http://redis.io/topics/distlock
driftFactor: 0.01, // multiplied by lock ttl to determine drift time
2024-09-25 22:27:51 +02:00
retryCount: 200,
2024-09-25 22:27:51 +02:00
retryDelay: 100,
2024-08-12 13:37:47 -04:00
// the max time in ms randomly added to retries
// to improve performance under high contention
// see https://www.awsarchitectureblog.com/2015/03/backoff.html
retryJitter: 200, // time in ms
// The minimum remaining time on a lock before an extension is automatically
// attempted with the `using` API.
2024-12-11 19:46:11 -03:00
automaticExtensionThreshold: 500 // time in ms
2024-08-12 13:37:47 -04:00
}
);