protected virtual void Dispose(bool disposing) // LUCENENET specific - implemented proper dispose pattern. { if (disposing) { if (isDisposed) { return; } UninterruptableMonitor.Enter(syncLock); try { if (isDisposed) { return; } if (cache != null) { cache.Clear(); cache = null; } isDisposed = true; } finally { UninterruptableMonitor.Exit(syncLock); } } }
internal NameInt32CacheLru(int limit) { this.cache = new NameCacheLru <FacetLabel>( limit, (name) => name, (name, prefixLength) => name.Subpath(prefixLength)); }
internal NameHashInt32CacheLru(int limit) { this.cache = new NameCacheLru <long>( limit, (name) => name.Int64HashCode(), (name, prefixLength) => name.Subpath(prefixLength).Int64HashCode()); }
/// <summary> /// Creates this with the specified method. /// </summary> public LruTaxonomyWriterCache(int cacheSize, LRUType lruType) { // TODO (Facet): choose between NameHashIntCacheLRU and NameIntCacheLRU. // For guaranteed correctness - not relying on no-collisions in the hash // function, NameIntCacheLRU should be used: // On the other hand, NameHashIntCacheLRU takes less RAM but if there // are collisions (which we never found) two different paths would be // mapped to the same ordinal... if (lruType == LRUType.LRU_HASHED) { this.cache = new NameHashInt32CacheLru(cacheSize); } else { this.cache = new NameInt32CacheLru(cacheSize); } }
protected virtual void Dispose(bool disposing) // LUCENENET specific - implemented proper dispose pattern. { if (disposing) { if (isDisposed) { return; } lock (syncLock) { if (isDisposed) { return; } if (cache != null) { cache.Clear(); cache = null; } isDisposed = true; } } }