コード例 #1
0
        private static void LogConnectionStatistics(string connName)
        {
            ConnectionMultiplexer conn;

            if (RedisConnectionWrapper.RedisConnections.TryGetValue(connName, out conn))
            {
                long priorPeriodCount = RedisConnectionWrapper.RedisStats.ContainsKey(connName) ? RedisConnectionWrapper.RedisStats[connName] : 0;

                long curCount = conn.GetCounters().Interactive.OperationCount;

                // log the sent commands
                RedisConnectionConfig.LogConnectionActionsCountDel(connName, curCount - priorPeriodCount);

                RedisConnectionWrapper.RedisStats[connName] = curCount;
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets the number of redis commands sent and received, and sets the count to 0 so the next time
        ///     we will not see double counts
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public static void GetConnectionsMessagesSent(object sender, ElapsedEventArgs e)
        {
            bool logCount = RedisConnectionConfig.LogConnectionActionsCountDel != null;

            if (logCount)
            {
                foreach (string connName in RedisConnectionWrapper.RedisConnections.Keys.ToList())
                {
                    try
                    {
                        ConnectionMultiplexer conn;
                        if (RedisConnectionWrapper.RedisConnections.TryGetValue(connName, out conn))
                        {
                            long priorPeriodCount = 0;
                            if (RedisConnectionWrapper.RedisStats.ContainsKey(connName))
                            {
                                priorPeriodCount = RedisConnectionWrapper.RedisStats[connName];
                            }

                            ServerCounters counts   = conn.GetCounters();
                            long           curCount = counts.Interactive.OperationCount;

                            // log the sent commands
                            RedisConnectionConfig.LogConnectionActionsCountDel(
                                connName,
                                curCount - priorPeriodCount);

                            RedisConnectionWrapper.RedisStats[connName] = curCount;
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }