/// <summary> /// Recupera as chaves selecionadas. /// </summary> /// <param name="cache">Instancia do cache de onde os itens estão inseridos.</param> /// <param name="evictSize"></param> /// <returns></returns> internal ArrayList GetSelectedKeys(CacheBase cache, long evictSize) { EvictionIndexEntry entry = null; ArrayList list = new ArrayList(); int num = 0; bool flag = false; long next = _head; if (_head != -1) { do { entry = _index[next] as EvictionIndexEntry; foreach (string str in entry.GetAllKeys()) { int itemSize = cache.GetItemSize(str); if (((num + itemSize) >= evictSize) && (num > 0)) { if ((evictSize - num) > ((itemSize + num) - evictSize)) { list.Add(str); } flag = true; break; } list.Add(str); num += itemSize; } next = entry.Next; }while (!flag && (next != -1)); } return(list); }
/// <summary> /// /// </summary> /// <param name="cache"></param> /// <param name="evictSize"></param> /// <returns></returns> private IList GetSelectedKeys(CacheBase cache, long evictSize) { ClusteredArrayList selectedKeys = new ClusteredArrayList(100); long sizeCount = 0; int prvsSize = 0; object key = null; bool selectionComplete = false; lock (_index.SyncRoot) { for (int i = 0; i < 5; i++) { if (!selectionComplete) { HashVector currentIndex = this._index[i]; if (currentIndex != null) { IDictionaryEnumerator ide = currentIndex.GetEnumerator(); while (ide.MoveNext()) { key = ide.Key; if (key != null) { int itemSize = cache.GetItemSize(key); if (sizeCount + itemSize >= evictSize && sizeCount > 0) { if (evictSize - sizeCount > (itemSize + sizeCount) - evictSize) { selectedKeys.Add(key); } selectionComplete = true; break; } else { selectedKeys.Add(key); sizeCount += itemSize; prvsSize = itemSize; } } } } } else { //break the outer loop. we have already picked up //the keys to be evicited. break; } } } return(selectedKeys); }
/// <summary> /// /// </summary> /// <param name="cache"></param> /// <param name="evictSize"></param> /// <returns></returns> private IList GetSelectedKeys(CacheBase cache, long evictSize, ref long totalsize) { ClusteredArrayList selectedKeys = new ClusteredArrayList(100); long sizeCount = 0; bool selectionComplete = false; lock (_index.SyncRoot) { for (int i = 0; i < 5; i++) { if (!selectionComplete) { HashVector currentIndex = _index[i]; if (currentIndex != null) { IDictionaryEnumerator ide = currentIndex.GetEnumerator(); while (ide.MoveNext()) { object key = ide.Key; if (key != null) { int itemSize = cache.GetItemSize(key); if (sizeCount + itemSize >= evictSize) { selectedKeys.Add(key); sizeCount += itemSize; totalsize = sizeCount; selectionComplete = true; break; } selectedKeys.Add(key); sizeCount += itemSize; } } } } else { break; } } } return(selectedKeys); }
private ArrayList GetSelectedKeys(CacheBase cache, long evictSize) { ArrayList list = new ArrayList(100); long num = 0; object key = null; bool flag = false; lock (_index.SyncRoot) { for (int i = 0; i < 5; i++) { if (flag) { return(list); } Hashtable hashtable = _index[i]; if (hashtable != null) { IDictionaryEnumerator enumerator = hashtable.GetEnumerator(); while (enumerator.MoveNext()) { key = enumerator.Key; if (key != null) { int itemSize = cache.GetItemSize(key); if (((num + itemSize) >= evictSize) && (num > 0)) { if ((evictSize - num) > ((itemSize + num) - evictSize)) { list.Add(key); } flag = true; break; } list.Add(key); num += itemSize; } } } } } return(list); }
internal IList GetSelectedKeys(CacheBase cache, long evictSize, ref long evictedSize) { EvictionIndexEntry entry; ClusteredArrayList selectedKeys = new ClusteredArrayList(); long totalSize = 0; bool selectionCompleted = false; long index = _head; if (_head != -1) { do { entry = _index[index] as EvictionIndexEntry; IList keys = entry.GetAllKeys(); foreach (string key in keys) { int itemSize = cache.GetItemSize(key); if (totalSize + itemSize >= evictSize) { selectedKeys.Add(key); totalSize += itemSize; evictedSize = totalSize; selectionCompleted = true; break; } else { selectedKeys.Add(key); totalSize += itemSize; } } index = entry.Next; }while (!selectionCompleted && index != -1); } return(selectedKeys); }