Ejemplo n.º 1
0
        /// <inheritdoc/>
        public async Task <bool> CanIdentifyAsync(int shardId, CancellationToken token)
        {
            token.ThrowIfCancellationRequested();

            try
            {
                await cache.AcquireLockAsync(GetCacheKey(shardId), token);
            }
            catch (OperationCanceledException)
            {
                return(false);
            }

            await cache.ExpiresAsync(GetCacheKey(shardId), TimeSpan.FromSeconds(5));

            return(true);
        }