Example #1
0
 /// <summary>
 /// Gets a RedisLock using the factory's set of redis endpoints. You should check the IsAcquired property before performing actions.
 /// Blocks and retries up to the specified time limits.
 /// </summary>
 /// <param name="resource">The resource string to lock on. Only one RedisLock should be acquired for any given resource at once.</param>
 /// <param name="expiryTime">How long the lock should be held for.
 /// RedisLocks will automatically extend if the process that created the RedisLock is still alive and the RedisLock hasn't been disposed.</param>
 /// <param name="waitTime">How long to block for until a lock can be acquired.</param>
 /// <param name="retryTime">How long to wait between retries when trying to acquire a lock.</param>
 /// <param name="cancellationToken">CancellationToken to abort waiting for blocking lock.</param>
 /// <returns>A RedisLock object.</returns>
 public async Task <RedisLock> CreateAsync(string resource, TimeSpan expiryTime, TimeSpan waitTime, TimeSpan retryTime, CancellationToken cancellationToken)
 {
     return(await RedisLock.CreateAsync(redisCaches, resource, expiryTime, waitTime, retryTime, cancellationToken).ConfigureAwait(false));
 }
Example #2
0
 /// <summary>
 /// Gets a RedisLock using the factory's set of redis endpoints. You should check the IsAcquired property before performing actions.
 /// </summary>
 /// <param name="resource">The resource string to lock on. Only one RedisLock should be acquired for any given resource at once.</param>
 /// <param name="expiryTime">How long the lock should be held for.
 /// RedisLocks will automatically extend if the process that created the RedisLock is still alive and the RedisLock hasn't been disposed.</param>
 /// <returns>A RedisLock object.</returns>
 public async Task <RedisLock> CreateAsync(string resource, TimeSpan expiryTime)
 {
     return(await RedisLock.CreateAsync(redisCaches, resource, expiryTime).ConfigureAwait(false));
 }