internal static async Task <RedisLock> CreateAsync( ICollection <RedisConnection> redisCaches, string resource, TimeSpan expiryTime, TimeSpan?waitTime = null, TimeSpan?retryTime = null) { var redisLock = new RedisLock( redisCaches, resource, expiryTime, waitTime, retryTime); await redisLock.StartAsync().ConfigureAwait(false); return(redisLock); }
internal static RedisLock Create( ICollection <RedisConnection> redisCaches, string resource, TimeSpan expiryTime, TimeSpan?waitTime = null, TimeSpan?retryTime = null) { var redisLock = new RedisLock( redisCaches, resource, expiryTime, waitTime, retryTime); redisLock.Start(); return(redisLock); }
/// <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)); }
/// <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> /// <returns>A RedisLock object.</returns> public RedisLock Create(string resource, TimeSpan expiryTime, TimeSpan waitTime, TimeSpan retryTime) { return(RedisLock.Create(redisCaches, resource, expiryTime, waitTime, retryTime)); }
/// <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)); }
/// <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 RedisLock Create(string resource, TimeSpan expiryTime, TimeSpan waitTime, TimeSpan retryTime, CancellationToken cancellationToken) { return(RedisLock.Create(redisCaches, resource, expiryTime, waitTime, retryTime, cancellationToken)); }
internal static async Task<RedisLock> CreateAsync( ICollection<RedisConnection> redisCaches, string resource, TimeSpan expiryTime, TimeSpan? waitTime = null, TimeSpan? retryTime = null) { var redisLock = new RedisLock( redisCaches, resource, expiryTime, waitTime, retryTime); await redisLock.StartAsync().ConfigureAwait(false); return redisLock; }
internal static RedisLock Create( ICollection<RedisConnection> redisCaches, string resource, TimeSpan expiryTime, TimeSpan? waitTime = null, TimeSpan? retryTime = null) { var redisLock = new RedisLock( redisCaches, resource, expiryTime, waitTime, retryTime); redisLock.Start(); return redisLock; }
public RedSyncLock(RedisContextProvider context, string key, int expiryTimeout = 30000, int waitTimeout = 10000, int retryTimeout = 100) { if (context == null) throw new ArgumentNullException(nameof(context)); _lock = context.LockFactory.Create(key, TimeSpan.FromMilliseconds(expiryTimeout), TimeSpan.FromMilliseconds(waitTimeout), TimeSpan.FromMilliseconds(retryTimeout)); }