Exemple #1
0
        public void Dispose()
        {
            if (_cache == null)
            {
                return;
            }

            using (_entryFactory as IDisposable)
            {
                _cacheLock.EnterWriteLock();
                try
                {
                    foreach (KeyValuePair <ulong, SegmentCacheEntry> kvp in _cache)
                    {
                        (kvp.Value as IDisposable)?.Dispose();
                    }

                    _cache.Clear();
                }
                finally
                {
                    _cacheLock.ExitWriteLock();
                    _cacheLock.Dispose();

                    _cacheLock    = null;
                    _cache        = null;
                    _entryFactory = null;
                }
            }
        }
Exemple #2
0
 public HeapSegmentDataCache(SegmentCacheEntryFactory entryFactory, uint entryCountWhenFull, bool cacheIsFullyPopulatedBeforeUse, long maxSize)
 {
     _entryFactory                   = entryFactory;
     _maxSize                        = maxSize;
     _entryCountWhenFull             = entryCountWhenFull;
     _cacheIsFullyPopulatedBeforeUse = cacheIsFullyPopulatedBeforeUse;
 }
 public HeapSegmentDataCache(SegmentCacheEntryFactory entryFactory, long maxSize)
 {
     _entryFactory = entryFactory;
     _maxSize      = maxSize;
 }