void IEvictionPolicy.Remove(object key, EvictionHint hint) { lock (_index.SyncRoot) { if (_index != null) { for (int i = 0; i < 5; i++) { if ((_index[i] != null) && _index[i].Contains(key)) { _index[i].Remove(key); if (_index[i].Count == 0) { _index[i] = null; } } } } } }
void IEvictionPolicy.Notify(object key, EvictionHint oldhint, EvictionHint newHint) { EvictionHint hint = newHint; if (hint != null) { CacheItemPriority priority = ((PriorityEvictionHint)hint).Priority; if (priority == CacheItemPriority.Default) { priority = _priority; ((PriorityEvictionHint)hint).Priority = _priority; } lock (_index.SyncRoot) { switch (priority) { case CacheItemPriority.Low: if (_index[0] == null) { _index[0] = new Hashtable(0x61a8, 0.7f); } _index[0][key] = hint; return; case CacheItemPriority.BelowNormal: if (_index[1] == null) { _index[1] = new Hashtable(0x61a8, 0.7f); } _index[1][key] = hint; return; case CacheItemPriority.Normal: if (_index[2] == null) { _index[2] = new Hashtable(0x61a8, 0.7f); } _index[2][key] = hint; return; case CacheItemPriority.AboveNormal: if (_index[3] == null) { _index[3] = new Hashtable(0x61a8, 0.7f); } _index[3][key] = hint; return; case CacheItemPriority.High: break; default: return; } if (_index[4] == null) { _index[4] = new Hashtable(0x61a8, 0.7f); } _index[4][key] = hint; } } }