/// <summary> /// Creates a new Thread safe instance of /// CachedDictionaryV2.CachedDictionary<TKey, TValue>. /// Both the TKey and TValue classes may Implement /// CachedDictionaryV2.ICloneable<T>. /// Newly created entries will expire after 60 seconds. /// </summary> /// <param name="equalityComparer">Any object that implements /// IEqualityComparer<TKey>.</param> /// <param name="newValueMethod">Any method or lambda expression /// that conforms to /// NewValueFromKey<TKey, TValue>.</param> public CachedDictionary (IEqualityComparer <TKey> equalityComparer , NewValueFromKey newValueMethod ) : this (equalityComparer , newValueMethod , 60 ) { }
/// <summary> /// Creates a new Thread safe instance of /// CachedDictionaryV2.CachedDictionary<TKey, TValue>. /// Both the TKey and TValue classes may Implement /// CachedDictionaryV2.ICloneable<T>. /// </summary> /// <param name="equalityComparer">Any object that implements /// IEqualityComparer<TKey>.</param> /// <param name="newValueMethod">Any method or lambda expression /// that conforms to /// NewValueFromKey<TKey, TValue>.</param> /// <param name="expirySeconds">Number of seconds before a /// newly created Dictionary /// entries expire.</param> public CachedDictionary (IEqualityComparer <TKey> equalityComparer , NewValueFromKey newValueMethod , uint expirySeconds ) : this (equalityComparer , newValueMethod , expirySeconds , 0 ) { }
public CachedDictionary (IEqualityComparer <TKey> equalityComparer , NewValueFromKey newValueMethod , uint expirySeconds , uint maxEntries ) : this (equalityComparer , newValueMethod , null , null , expirySeconds , maxEntries ) { }
public CachedDictionary (IEqualityComparer <TKey> equalityComparer , NewValueFromKey newValueMethod , CloneKeyMethod cloneKeyMethod , CloneValueMethod cloneValueMethod , uint expirySeconds , uint maxEntries ) { dictionary = new Dictionary <TKey, CachedDictionary <TKey, TValue> .Entry> (equalityComparer ) ; this.newValueMethod = newValueMethod; KeyIsCloneable = false; KeyIsCloneableExternalMethod = false; if (typeof(TKey).GetInterfaces().Contains(typeof(ICloneable <TKey>))) { KeyIsCloneable = true; } else { this.cloneKeyMethod = cloneKeyMethod; } ValueIsCloneable = false; ValueIsCloneableExternalMethod = false; if (typeof(TValue).GetInterfaces().Contains(typeof(ICloneable <TValue>))) { ValueIsCloneable = true; } else { this.cloneValueMethod = cloneValueMethod; } ExpirySeconds = expirySeconds; MaxEntries = maxEntries; HitCount = 0; MissCount = 0; NewCount = 0; RemovedCount = 0; ExpiredCount = 0; KeyIsCloneableExternalMethod = this.cloneKeyMethod != null; ValueIsCloneableExternalMethod = this.cloneValueMethod != null; }