Exemplo n.º 1
0
 private void NFileCache_MaxCacheSizeReached(object sender, FileCacheEventArgs e)
 {
     // Shrink the cache to 75% of the max size
     // that way there's room for it to grow a bit
     // before we have to do this again.
     Trim((long)(MaxCacheSize * 0.75));
 }
Exemplo n.º 2
0
        private void MaxCacheSizeReached(object sender, FileCacheEventArgs e)
        {
            //first try removing all non-completed items
            foreach (var odds in _cache.GetKeys()
                        .Select(key => _cache.GetCacheItem(key))
                        .Select(item => item.Value)
                        .OfType<TexasHoldemOdds>()
                        .Where(odds => !odds.Completed))
            {
                try
                {
                    _cache.Remove(odds.GetCacheKey());
                }
                catch { }
            }

            //if that has bought us some space
            if (_cache.GetCacheSize() < e.CurrentCacheSize)
            {
                //bail
                return;
            }

            //final last ditch approach
            //remove everything, and re-prime the cache
            _cache.Flush();
            PrimeCache();
        }
Exemplo n.º 3
0
 private void FileCache_MaxCacheSizeReached(object sender, FileCacheEventArgs e)
 {
     Task.Factory.StartNew((Action)(() =>
     {
         // Shrink the cache to 75% of the max size
         // that way there's room for it to grow a bit
         // before we have to do this again.
         long newSize = ShrinkCacheToSize((long)(MaxCacheSize * 0.75));
     }));
 }