Exemplo n.º 1
0
        internal static void DeactivateClient(RedisClient client)
        {
            Interlocked.Increment(ref TotalDeactivatedClients);

            if (RedisConfig.DeactivatedClientsExpiry == TimeSpan.Zero)
            {
                client.DisposeConnection();
                return;
            }

            var deactivatedAt = client.DeactivatedAt ?? DateTime.UtcNow;
            client.DeactivatedAt = deactivatedAt;

            if (!DeactivatedClients.TryAdd(client, deactivatedAt))
                client.DisposeConnection();
        }
Exemplo n.º 2
0
        async ValueTask IRedisPipelineSharedAsync.FlushAsync(CancellationToken token)
        {
            // flush send buffers
            await RedisClient.FlushSendBufferAsync(token).ConfigureAwait(false);

            RedisClient.ResetSendBuffer();

            try
            {
                //receive expected results
                foreach (var queuedCommand in QueuedCommands)
                {
                    await queuedCommand.ProcessResultAsync(token).ConfigureAwait(false);
                }
            }
            catch (Exception)
            {
                // The connection cannot be reused anymore. All queued commands have been sent to redis. Even if a new command is executed, the next response read from the
                // network stream can be the response of one of the queued commands, depending on when the exception occurred. This response would be invalid for the new command.
                RedisClient.DisposeConnection();
                throw;
            }

            ClosePipeline();
        }
Exemplo n.º 3
0
        internal static void DeactivateClient(RedisClient client)
        {
            Interlocked.Increment(ref TotalDeactivatedClients);

            if (RedisConfig.DeactivatedClientsExpiry == TimeSpan.Zero)
            {
                client.DisposeConnection();
                return;
            }

            var deactivatedAt = client.DeactivatedAt ?? DateTime.UtcNow;

            client.DeactivatedAt = deactivatedAt;

            if (!DeactivatedClients.TryAdd(client, deactivatedAt))
            {
                client.DisposeConnection();
            }
        }
Exemplo n.º 4
0
 protected void Dispose(RedisClient redisClient)
 {
     if (redisClient == null)
     {
         return;
     }
     try
     {
         redisClient.DisposeConnection();
     }
     catch (Exception ex)
     {
         Log.Error($"Error when trying to dispose of RedisClient to host {redisClient.Host}:{redisClient.Port}", ex);
     }
 }
Exemplo n.º 5
0
 protected void Dispose(RedisClient redisClient)
 {
     if (redisClient == null)
     {
         return;
     }
     try
     {
         redisClient.DisposeConnection();
     }
     catch (Exception ex)
     {
         Log.Error(string.Format(
                       "Error when trying to dispose of RedisClient to host {0}:{1}",
                       redisClient.Host, redisClient.Port), ex);
     }
 }
        /// <summary>
        /// Flush send buffer, and read responses
        /// </summary>
        public void Flush()
        {
            // flush send buffers
            RedisClient.FlushAndResetSendBuffer();

            try
            {
                //receive expected results
                foreach (var queuedCommand in QueuedCommands)
                {
                    queuedCommand.ProcessResult();
                }
            }
            catch (Exception)
            {
                // The connection cannot be reused anymore. All queued commands have been sent to redis. Even if a new command is executed, the next response read from the
                // network stream can be the response of one of the queued commands, depending on when the exception occurred. This response would be invalid for the new command.
                RedisClient.DisposeConnection();
                throw;
            }

            ClosePipeline();
        }
		protected void Dispose(RedisClient redisClient)
		{
			if (redisClient == null) return;
			try
			{
				redisClient.DisposeConnection();
			}
			catch (Exception ex)
			{
				Log.Error(string.Format(
					"Error when trying to dispose of RedisClient to host {0}:{1}",
					redisClient.Host, redisClient.Port), ex);
			}
		}