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); }
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); }
protected override R GetOrAddCore(T args) => _cache.GetOrAdd(args, _function).Value;