Пример #1
0
 /// <summary>
 /// <para>
 /// Returns the corresponding statistical information of the
 /// <see cref="CacheStatsCounterType"/> type.
 /// </para>
 /// <para>
 /// If the cache handles is configured to disable statistics, the method will always return zero.
 /// </para>
 /// </summary>
 /// <remarks>
 /// In multithreaded environments the counters can be changed while reading. Do not rely on
 /// those counters as they might not be 100% accurate.
 /// </remarks>
 /// <example>
 /// <code>
 /// <![CDATA[
 /// var cache = CacheFactory.FromConfiguration("myCache");
 ///
 /// foreach (var handle in cache.CacheHandles)
 /// {
 ///    var stats = handle.Stats;
 ///    Console.WriteLine(string.Format(
 ///            "Items: {0}, Hits: {1}, Miss: {2}, Remove: {3}, ClearRegion: {4}, Clear: {5}, Adds: {6}, Puts: {7}, Gets: {8}",
 ///                stats.GetStatistic(CacheStatsCounterType.Items),
 ///                stats.GetStatistic(CacheStatsCounterType.Hits),
 ///                stats.GetStatistic(CacheStatsCounterType.Misses),
 ///                stats.GetStatistic(CacheStatsCounterType.RemoveCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.ClearRegionCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.ClearCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.AddCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.PutCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.GetCalls)
 ///            ));
 /// }
 /// ]]>
 /// </code>
 /// </example>
 /// <param name="type">The stats type to retrieve the number for.</param>
 /// <returns>A number representing the counts for the specified <see cref="CacheStatsCounterType"/>.</returns>
 public long GetStatistic(CacheStatsCounterType type)
 {
     if (!_isStatsEnabled)
     {
         return(0L);
     }
     return(_counter.Get(type));
 }
Пример #2
0
        /// <summary>
        /// <para>
        /// Returns the corresponding statistical information of the
        /// <see cref="CacheStatsCounterType"/> type.
        /// </para>
        /// <para>
        /// If the cache handles is configured to disable statistics, the method will always return zero.
        /// </para>
        /// </summary>
        /// <remarks>
        /// In multi threaded environments the counters can be changed while reading. Do not rely on
        /// those counters as they might not be 100% accurate.
        /// </remarks>
        /// <example>
        /// <code>
        /// <![CDATA[
        /// var cache = CacheFactory.FromConfiguration("myCache");
        ///
        /// foreach (var handle in cache.CacheHandles)
        /// {
        ///    var stats = handle.Stats;
        ///    var region = "myRegion";
        ///    Console.WriteLine(string.Format(
        ///            "Items: {0}, Hits: {1}, Miss: {2}, Remove: {3}, ClearRegion: {4}, Clear: {5}, Adds: {6}, Puts: {7}, Gets: {8}",
        ///                stats.GetStatistic(CacheStatsCounterType.Items, region),
        ///                stats.GetStatistic(CacheStatsCounterType.Hits, region),
        ///                stats.GetStatistic(CacheStatsCounterType.Misses, region),
        ///                stats.GetStatistic(CacheStatsCounterType.RemoveCalls, region),
        ///                stats.GetStatistic(CacheStatsCounterType.ClearRegionCalls, region),
        ///                stats.GetStatistic(CacheStatsCounterType.ClearCalls, region),
        ///                stats.GetStatistic(CacheStatsCounterType.AddCalls, region),
        ///                stats.GetStatistic(CacheStatsCounterType.PutCalls, region),
        ///                stats.GetStatistic(CacheStatsCounterType.GetCalls, region)
        ///            ));
        /// }
        /// ]]>
        /// </code>
        /// </example>
        /// <param name="type">The stats type to retrieve the number for.</param>
        /// <param name="region">
        /// The region. The returned value will represent the counter of the region only.
        /// </param>
        /// <returns>
        /// A number representing the counts for the specified <see cref="CacheStatsCounterType"/>
        /// and region.
        /// </returns>
        public long GetStatistic(CacheStatsCounterType type, string region)
        {
            if (!_isStatsEnabled)
            {
                return(0L);
            }

            NotNullOrWhiteSpace(region, nameof(region));

            var counter = GetCounter(region);

            return(counter.Get(type));
        }
Пример #3
0
        /// <summary>
        /// <para>
        /// Returns the corresponding statistical information of the
        /// <see cref="CacheStatsCounterType"/> type.
        /// </para>
        /// <para>
        /// If the cache handles is configured to disable statistics, the method will always return zero.
        /// </para>
        /// </summary>
        /// <remarks>
        /// In multi threaded environments the counters can be changed while reading. Do not rely on
        /// those counters as they might not be 100% accurate.
        /// </remarks>
        /// <example>
        /// <code>
        /// <![CDATA[
        /// var cache = CacheFactory.FromConfiguration("myCache");
        ///
        /// foreach (var handle in cache.CacheHandles)
        /// {
        ///    var stats = handle.Stats;
        ///    var region = "myRegion";
        ///    Console.WriteLine(string.Format(
        ///            "Items: {0}, Hits: {1}, Miss: {2}, Remove: {3}, ClearRegion: {4}, Clear: {5}, Adds: {6}, Puts: {7}, Gets: {8}",
        ///                stats.GetStatistic(CacheStatsCounterType.Items, region),
        ///                stats.GetStatistic(CacheStatsCounterType.Hits, region),
        ///                stats.GetStatistic(CacheStatsCounterType.Misses, region),
        ///                stats.GetStatistic(CacheStatsCounterType.RemoveCalls, region),
        ///                stats.GetStatistic(CacheStatsCounterType.ClearRegionCalls, region),
        ///                stats.GetStatistic(CacheStatsCounterType.ClearCalls, region),
        ///                stats.GetStatistic(CacheStatsCounterType.AddCalls, region),
        ///                stats.GetStatistic(CacheStatsCounterType.PutCalls, region),
        ///                stats.GetStatistic(CacheStatsCounterType.GetCalls, region)
        ///            ));
        /// }
        /// ]]>
        /// </code>
        /// </example>
        /// <param name="type">The stats type to retrieve the number for.</param>
        /// <param name="region">
        /// The region. The returned value will represent the counter of the region only.
        /// </param>
        /// <returns>
        /// A number representing the counts for the specified <see cref="CacheStatsCounterType"/>
        /// and region.
        /// </returns>
        public long GetStatistic(CacheStatsCounterType type, string region)
        {
            if (!this.isStatsEnabled)
            {
                return(0L);
            }

            if (string.IsNullOrWhiteSpace(region))
            {
                throw new ArgumentNullException("region");
            }

            var counter = this.GetCounter(region);

            return(counter.Get(type));
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CacheStatistic"/> class.
 /// </summary>
 /// <param name="counterType">Type of the counter.</param>
 /// <param name="count">The count.</param>
 public CacheStatistic(CacheStatsCounterType counterType, long count)
 {
     CounterType = counterType;
     Count       = count;
 }
Пример #5
0
 public void Add(CacheStatsCounterType type, long value)
 {
     Interlocked.Add(ref _counters[(int)type], value);
 }
Пример #6
0
 public void Set(CacheStatsCounterType type, long value)
 {
     Interlocked.Exchange(ref _counters[(int)type], value);
 }
Пример #7
0
 public void Increment(CacheStatsCounterType type)
 {
     Interlocked.Increment(ref _counters[(int)type]);
 }
Пример #8
0
 public long Get(CacheStatsCounterType type) => _counters[(int)type];
Пример #9
0
 public void Decrement(CacheStatsCounterType type)
 {
     Interlocked.Decrement(ref this.counters[(int)type]);
 }
Пример #10
0
 /// <summary>
 /// <para>
 /// Returns the corresponding statistical information of the
 /// <see cref="CacheStatsCounterType"/> type.
 /// </para>
 /// <para>
 /// If the cache handles is configured to disable statistics, the method will always return zero.
 /// </para>
 /// </summary>
 /// <remarks>
 /// In multithreaded environments the counters can be changed while reading. Do not rely on
 /// those counters as they might not be 100% accurate.
 /// </remarks>
 /// <example>
 /// <code>
 /// <![CDATA[
 /// var cache = CacheFactory.FromConfiguration("myCache");
 ///
 /// foreach (var handle in cache.CacheHandles)
 /// {
 ///    var stats = handle.Stats;
 ///    Console.WriteLine(string.Format(
 ///            "Items: {0}, Hits: {1}, Miss: {2}, Remove: {3}, ClearRegion: {4}, Clear: {5}, Adds: {6}, Puts: {7}, Gets: {8}",
 ///                stats.GetStatistic(CacheStatsCounterType.Items),
 ///                stats.GetStatistic(CacheStatsCounterType.Hits),
 ///                stats.GetStatistic(CacheStatsCounterType.Misses),
 ///                stats.GetStatistic(CacheStatsCounterType.RemoveCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.ClearRegionCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.ClearCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.AddCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.PutCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.GetCalls)
 ///            ));
 /// }
 /// ]]>
 /// </code>
 /// </example>
 /// <param name="type">The stats type to retrieve the number for.</param>
 /// <returns>A number representing the counts for the specified <see cref="CacheStatsCounterType"/>.</returns>
 public long GetStatistic(CacheStatsCounterType type)
 {
     return(this.GetStatistic(type, NullRegionKey));
 }
Пример #11
0
 public void Set(CacheStatsCounterType type, long value)
 {
     Interlocked.Exchange(ref this.counters[(int)type], value);
 }
Пример #12
0
 public void Increment(CacheStatsCounterType type)
 {
     Interlocked.Increment(ref this.counters[(int)type]);
 }
Пример #13
0
 public long Get(CacheStatsCounterType type)
 {
     var result = this.counters[(int)type];
     return result;
 }
Пример #14
0
 public void Add(CacheStatsCounterType type, long value)
 {
     Interlocked.Add(ref this.counters[(int)type], value);
 }
Пример #15
0
 public long Get(CacheStatsCounterType type) => this.counters[(int)type];
Пример #16
0
 /// <summary>
 /// <para>
 /// Returns the corresponding statistical information of the
 /// <see cref="CacheStatsCounterType"/> type.
 /// </para>
 /// <para>
 /// If the cache handles is configured to disable statistics, the method will always return zero.
 /// </para>
 /// </summary>
 /// <remarks>
 /// In multithreaded environments the counters can be changed while reading. Do not rely on
 /// those counters as they might not be 100% accurate.
 /// </remarks>
 /// <example>
 /// <code>
 /// <![CDATA[
 /// var cache = CacheFactory.FromConfiguration("myCache");
 ///
 /// foreach (var handle in cache.CacheHandles)
 /// {
 ///    var stats = handle.Stats;
 ///    Console.WriteLine(string.Format(
 ///            "Items: {0}, Hits: {1}, Miss: {2}, Remove: {3}, ClearRegion: {4}, Clear: {5}, Adds: {6}, Puts: {7}, Gets: {8}",
 ///                stats.GetStatistic(CacheStatsCounterType.Items),
 ///                stats.GetStatistic(CacheStatsCounterType.Hits),
 ///                stats.GetStatistic(CacheStatsCounterType.Misses),
 ///                stats.GetStatistic(CacheStatsCounterType.RemoveCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.ClearRegionCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.ClearCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.AddCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.PutCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.GetCalls)
 ///            ));
 /// }
 /// ]]>
 /// </code>
 /// </example>
 /// <param name="type">The stats type to retrieve the number for.</param>
 /// <returns>A number representing the counts for the specified <see cref="CacheStatsCounterType"/>.</returns>
 public long GetStatistic(CacheStatsCounterType type) => this.GetStatistic(type, NullRegionKey);
Пример #17
0
 /// <summary>
 /// <para>
 /// Returns the corresponding statistical information of the
 /// <see cref="CacheStatsCounterType"/> type.
 /// </para>
 /// <para>
 /// If the cache handles is configured to disable statistics, the method will always return zero.
 /// </para>
 /// </summary>
 /// <remarks>
 /// In multithreaded environments the counters can be changed while reading. Do not rely on
 /// those counters as they might not be 100% accurate.
 /// </remarks>
 /// <example>
 /// <code>
 /// <![CDATA[
 /// var cache = CacheFactory.FromConfiguration("myCache");
 ///
 /// foreach (var handle in cache.CacheHandles)
 /// {
 ///    var stats = handle.Stats;
 ///    Console.WriteLine(string.Format(
 ///            "Items: {0}, Hits: {1}, Miss: {2}, Remove: {3}, ClearRegion: {4}, Clear: {5}, Adds: {6}, Puts: {7}, Gets: {8}",
 ///                stats.GetStatistic(CacheStatsCounterType.Items),
 ///                stats.GetStatistic(CacheStatsCounterType.Hits),
 ///                stats.GetStatistic(CacheStatsCounterType.Misses),
 ///                stats.GetStatistic(CacheStatsCounterType.RemoveCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.ClearRegionCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.ClearCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.AddCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.PutCalls),
 ///                stats.GetStatistic(CacheStatsCounterType.GetCalls)
 ///            ));
 /// }
 /// ]]>
 /// </code>
 /// </example>
 /// <param name="type">The stats type to retrieve the number for.</param>
 /// <returns>A number representing the counts for the specified <see cref="CacheStatsCounterType"/>.</returns>
 public long GetStatistic(CacheStatsCounterType type) => GetStatistic(type, _nullRegionKey);
        public long Get(CacheStatsCounterType type)
        {
            var result = this.counters[(int)type];

            return(result);
        }