コード例 #1
0
        public DistributedCacheWithMetrics(DistributedCacheOptions <TCacheInstance> options, IMetrics metrics,
                                           AllowedMetrics <DistributedCacheWithMetrics <TCacheInstance> > settings) : base(options)
        {
            this.Helper = new MetricsHelper <TCacheInstance>(metrics, settings.AllowedCacheMetrics);

            if (settings.AllowedCacheMetrics.HasFlag(CacheMetrics.HitRatio))
            {
                this.Helper.MetricsObj.RegisterOneMinuteRate(
                    Metrics.Distributed.HitRatio,
                    Metrics.Distributed.HitCount,
                    Metrics.Distributed.TotalCount,
                    this.Helper.MetricsTags);
            }

            if (settings.AllowedCacheMetrics.HasFlag(CacheMetrics.ErrorRatio))
            {
                this.Helper.MetricsObj.RegisterOneMinuteRate(
                    Metrics.Distributed.ErrorRatio,
                    Metrics.Distributed.ErrorCount,
                    Metrics.Distributed.TotalCount,
                    this.Helper.MetricsTags);
            }

            options.OnGetError += Options_OnGetError;
        }
コード例 #2
0
 public MemoryCacheWithMetrics(MemoryCacheOptions <TCacheInstance> options, IMetrics metrics,
                               AllowedMetrics <MemoryCacheWithMetrics <TCacheInstance> > settings) : base(options)
 {
     this.Helper = new MetricsHelper <TCacheInstance>(metrics, settings.AllowedCacheMetrics);
     if (settings.AllowedCacheMetrics.HasFlag(CacheMetrics.HitRatio))
     {
         this.Helper.MetricsObj.RegisterOneMinuteRate(
             Metrics.Memory.HitRatio,
             Metrics.Memory.HitCount,
             Metrics.Memory.TotalCount,
             this.Helper.MetricsTags);
     }
 }