/// ----------------------------------------------------------------- /// <summary> /// </summary> /// ----------------------------------------------------------------- protected void PurgeCache() { int now = Util.EnvironmentTickCount(); if (Util.EnvironmentTickCountCompare(now, LastPurge) < PurgeInterval) { return; } List <UUID> purgelist = new List <UUID>(); foreach (KeyValuePair <UUID, CapabilityInfo> kvp in CapabilityCollection) { int span = kvp.Value.LifeSpan; int refresh = kvp.Value.LastRefresh; if (span > 0 && Util.EnvironmentTickCountCompare(now, refresh) > span) { purgelist.Add(kvp.Key); } } foreach (UUID cap in purgelist) { CapabilityCollection.Remove(cap); } LastPurge = now; }
/// ----------------------------------------------------------------- /// <summary> /// </summary> /// ----------------------------------------------------------------- public bool RemoveCapability(UUID cap) { lock (CapabilityCollection) { if (CapabilityCollection.ContainsKey(cap)) { CapabilityCollection.Remove(cap); return(true); } } return(false); }