public void TrackViewModelCreatedOrUpdated(string routeName, string viewModelCacheId, int jsonLength) { if (routeName == options.RouteName) { return; } lock (viewModelEntriesLocker) { var cacheKey = new ViewModelCacheKey(routeName, viewModelCacheId); if (!viewModelEntries.TryGetValue(cacheKey, out var entry)) { entry = new ViewModelStatsEntry() { RouteName = routeName, ViewModelCacheId = viewModelCacheId, InMemoryStoreSizeInBytes = store.Retrieve(viewModelCacheId).Length, JsonSizeInBytes = jsonLength, ReuseCount = 1 }; viewModelEntries.Add(cacheKey, entry); } else { entry.ReuseCount++; } } }
public bool Equals(ViewModelCacheKey other) { return(RouteName == other.RouteName && ViewModelId == other.ViewModelId); }