protected override R GetOrAddCore(T args)
                {
#if DEBUG
                    var swTotal = Stopwatch.StartNew();
                    _accessCount++;
#endif
                    var entry = _cache.GetOrAdd(args, _function);

                    MostRecent(entry);
#if DEBUG
                    var metrics = entry.GetMetrics();
                    metrics.HitCount++;
                    metrics.TotalDuration += swTotal.Elapsed;
#endif
                    return(entry.Value);
                }
Ejemplo n.º 2
0
                protected override R GetOrAddCore(T args)
                {
#if DEBUG
                    _accessCount++;
#endif
                    var swTotalStart = _stopwatch.ElapsedTicks;

                    var entry = _cache.GetOrAdd(args, _function);

                    var duration   = new TimeSpan(_stopwatch.ElapsedTicks - swTotalStart);
                    var accessTime = _stopwatch.Elapsed;

                    entry.HitCount++;
                    entry.TotalDuration += duration;
                    entry.LastAccessTime = accessTime;

                    return(entry.Value);
                }
Ejemplo n.º 3
0
 protected override R GetOrAddCore(T args) => _cache.GetOrAdd(args, _function).Value;