コード例 #1
0
 /// <summary>
 /// Acquire distributed lock with random nonce in repeater loop
 /// </summary>
 /// <param name="f"></param>
 /// <param name="resource">Resource name for lock</param>
 /// <param name="cancellationToken">Token to cancel repeater loop</param>
 /// <returns></returns>
 public static Redlock Create(this IRedlockFactory f, string resource, CancellationToken cancellationToken)
 => f.Create(resource, f.DefaultTtl(resource), cancellationToken);
コード例 #2
0
 /// <summary>
 /// Acquire distributed lock with random nonce and default max wait between attempts
 /// </summary>
 /// <param name="f"></param>
 /// <param name="resource">Resource name for lock</param>
 /// <param name="lockTimeToLive">
 /// Time to live of acquired lock.
 /// Attention! If this ttl are expired, code that the lock uses has a safety violation
 /// </param>
 /// <param name="repeater"></param>
 /// <typeparam name="T">Type of repeater</typeparam>
 /// <returns></returns>
 public static Task <Redlock> CreateAsync <T>(this IRedlockFactory f, string resource, TimeSpan lockTimeToLive, T repeater)
     where T : IRedlockRepeater => f.CreateAsync(resource, lockTimeToLive, repeater, f.DefaultMaxWaitMsBetweenReplays(resource, lockTimeToLive));
コード例 #3
0
 /// <summary>
 /// Acquire distributed lock with random nonce in repeater loop
 /// </summary>
 /// <param name="f"></param>
 /// <param name="resource">Resource name for lock</param>
 /// <returns></returns>
 public static Redlock Create(this IRedlockFactory f, string resource)
 => f.Create(resource, f.DefaultTtl(resource));
コード例 #4
0
 /// <summary>
 /// Acquire distributed lock with random nonce in repeater loop
 /// </summary>
 /// <param name="f"></param>
 /// <param name="resource">Resource name for lock</param>
 /// <param name="lockTimeToLive">
 /// Time to live of acquired lock.
 /// Attention! If this ttl are expired, code that the lock uses has a safety violation
 /// </param>
 /// <param name="cancellationToken">Token to cancel repeater loop</param>
 /// <returns></returns>
 public static Redlock Create(
     this IRedlockFactory f, string resource, TimeSpan lockTimeToLive, CancellationToken cancellationToken
     ) => f.Create(resource, lockTimeToLive, new CancellationRedlockRepeater(cancellationToken));
コード例 #5
0
 /// <summary>
 /// Acquire distributed lock with random nonce in repeater loop
 /// </summary>
 /// <param name="f"></param>
 /// <param name="resource">Resource name for lock</param>
 /// <param name="lockTimeToLive">
 /// Time to live of acquired lock.
 /// Attention! If this ttl are expired, code that the lock uses has a safety violation
 /// </param>
 /// <returns></returns>
 public static Redlock Create(this IRedlockFactory f, string resource, TimeSpan lockTimeToLive)
 => f.Create(resource, lockTimeToLive, 3);
コード例 #6
0
 /// <summary>
 /// Acquire distributed lock with random nonce in repeater loop
 /// </summary>
 /// <param name="f"></param>
 /// <param name="resource">Resource name for lock</param>
 /// <param name="lockTimeToLive">
 /// Time to live of acquired lock.
 /// Attention! If this ttl are expired, code that the lock uses has a safety violation
 /// </param>
 /// <param name="maxRetryCount">Max retries if lock unable to acquire</param>
 /// <returns></returns>
 public static Redlock Create(this IRedlockFactory f, string resource, TimeSpan lockTimeToLive, int maxRetryCount)
 => f.Create(resource, lockTimeToLive, new MaxRetriesRedlockRepeater(maxRetryCount));
コード例 #7
0
 /// <summary>
 /// Acquire distributed lock with random nonce in repeater loop
 /// </summary>
 /// <param name="f"></param>
 /// <param name="resource">Resource name for lock</param>
 /// <param name="cancellationToken">Token to cancel repeater loop</param>
 /// <returns></returns>
 public static Task <Redlock> CreateAsync(this IRedlockFactory f, string resource, CancellationToken cancellationToken)
 => f.CreateAsync(resource, f.DefaultTtl(resource), cancellationToken);
コード例 #8
0
 /// <summary>
 /// Acquire distributed lock with random nonce in repeater loop
 /// </summary>
 /// <param name="f"></param>
 /// <param name="resource">Resource name for lock</param>
 /// <returns></returns>
 public static Task <Redlock> CreateAsync(this IRedlockFactory f, string resource)
 => f.CreateAsync(resource, f.DefaultTtl(resource));
コード例 #9
0
 /// <summary>
 /// Acquire distributed lock with random nonce in repeater loop
 /// </summary>
 /// <param name="f"></param>
 /// <param name="resource">Resource name for lock</param>
 /// <param name="lockTimeToLive">
 /// Time to live of acquired lock.
 /// Attention! If this ttl are expired, code that the lock uses has a safety violation
 /// </param>
 /// <returns></returns>
 public static Task <Redlock> CreateAsync(this IRedlockFactory f, string resource, TimeSpan lockTimeToLive)
 => f.CreateAsync(resource, lockTimeToLive, 3);