/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { if (disposed) { return; } GC.SuppressFinalize(this); disposed = true; definitions.Clear(); definitions = null; directoryKeys.Clear(); directoryKeys = null; fileKeys.Clear(); fileKeys = null; typeAndIdKeys.Clear(); typeAndIdKeys = null; typeKeys.Clear(); typeKeys = null; allFileKeys.Clear(); allFileKeys = null; childHierarchicalDefinitions.Clear(); childHierarchicalDefinitions = null; mainHierarchalDefinitions.Clear(); mainHierarchalDefinitions = null; trie = null; resetDefinitions.Clear(); resetDefinitions = null; }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { if (disposed) { return; } disposed = true; definitions.Clear(); definitions = null; fileKeys.Clear(); fileKeys = null; typeAndIdKeys.Clear(); typeAndIdKeys = null; typeKeys.Clear(); typeKeys = null; allFileKeys.Clear(); allFileKeys = null; childHierarchicalDefinitions.Clear(); childHierarchicalDefinitions = null; mainHierarchalDefinitions.Clear(); mainHierarchalDefinitions = null; trie = null; }
/// <summary> /// Reads any existing cache index file, building the in-memory representation, without bringing in actual item data until actually requested. /// </summary> private void RestoreIndex() { if (DefaultStorageStrategy == CacheStorageStrategy.OnlyMemory) { return; } try { var fn = Path.Combine(RootDirectory, "index.json"); if (File.Exists(fn)) { using (var jr = new JsonTextReader(new StreamReader(File.OpenRead(fn)))) { // Should be start array jr.Read(); while (jr.Read() && jr.TokenType != JsonToken.EndArray) { // Should be start object jr.Read(); var i = new MFSEntry(); i.FileName = jr.ReadAsString(); jr.Read(); i.ObjectTypeName = jr.ReadAsString(); jr.Read(); i.ByQuerySHA = jr.ReadAsString(); jr.Read(); i.QueryForAll = jr.ReadAsBoolean().GetValueOrDefault(); jr.Read(); i.ByIdentityComposite = jr.ReadAsString(); jr.Read(); i.ExpiryDate = jr.ReadAsDateTime().GetValueOrDefault(); jr.Read(); if (i.ExpiryDate > DateTime.Now) { i.Active = true; i.Persisted = true; _index.Add(i); } } } } else { FlushAll(RootDirectory); _index.Clear(); } } catch (Exception ex) { CEFDebug.WriteInfo($"Exception in cache restore index: {ex.Message}"); // Any problems, go with an empty cache FlushAll(RootDirectory); _index.Clear(); } }