/// <inheritdoc/> public void Init(IDictionary <IVersionedDataKind, IDictionary <string, IVersionedData> > items) { Exception failure = null; try { _core.InitInternal(items); } catch (Exception e) { failure = e; } if (_itemCache != null && _allCache != null) { _itemCache.Clear(); _allCache.Clear(); if (failure != null && !_caching.IsInfiniteTtl) { // Normally, if the underlying store failed to do the update, we do not want to update the cache - // the idea being that it's better to stay in a consistent state of having old data than to act // like we have new data but then suddenly fall back to old data when the cache expires. However, // if the cache TTL is infinite, then it makes sense to update the cache always. throw failure; } foreach (var e0 in items) { var kind = e0.Key; _allCache.Set(kind, e0.Value.ToImmutableDictionary()); foreach (var e1 in e0.Value) { _itemCache.Set(new CacheKey(kind, e1.Key), e1.Value); } } } if (failure is null || _caching.IsInfiniteTtl) { _inited = true; } if (failure != null) { throw failure; } }
/// <summary> /// <see cref="IFeatureStore.Init"/> /// </summary> public void Init(IDictionary <IVersionedDataKind, IDictionary <string, IVersionedData> > items) { _core.InitInternal(items); _inited = true; if (_itemCache != null && _allCache != null) { _itemCache.Clear(); _allCache.Clear(); foreach (var e0 in items) { var kind = e0.Key; _allCache.Set(kind, e0.Value); foreach (var e1 in e0.Value) { _itemCache.Set(new CacheKey(kind, e1.Key), e1.Value); } } } }