forked from tsai/budibase
8 changed files with 130 additions and 9 deletions
@ -1,4 +1,5 @@ |
|||||
module.exports = { |
module.exports = { |
||||
Client: require("./src/redis"), |
Client: require("./src/redis"), |
||||
utils: require("./src/redis/utils"), |
utils: require("./src/redis/utils"), |
||||
|
clients: require("./src/redis/authRedis"), |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,21 @@ |
|||||
|
import Redlock from "redlock" |
||||
|
|
||||
|
export const getRedlock = (redisClient: any, opts = { retryCount: 10 }) => { |
||||
|
return new Redlock([redisClient], { |
||||
|
// the expected clock drift; for more details
|
||||
|
// see http://redis.io/topics/distlock
|
||||
|
driftFactor: 0.01, // multiplied by lock ttl to determine drift time
|
||||
|
|
||||
|
// the max number of times Redlock will attempt
|
||||
|
// to lock a resource before erroring
|
||||
|
retryCount: opts.retryCount, |
||||
|
|
||||
|
// the time in ms between attempts
|
||||
|
retryDelay: 200, // time in ms
|
||||
|
|
||||
|
// 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
|
||||
|
}) |
||||
|
} |
||||
Loading…
Reference in new issue