Evolution/Evolution/Utils/Cache.cs
/// <summary>
/// Adds the specified key value pair to the cache.
/// If the added key already exists, the existent value is replaced.
/// It must be noted that if a new element is added, and the <see cref="CacheMaximumSize"/> is reached a
/// CleanUp operation would be executed, thus, blocking the method return until it is finalized
/// </summary>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
Adds the specified key value pair to the cache.
If the added key already exists, the existent value is replaced.
It must be noted that if a new element is added, and the  is reached a
CleanUp operation would be executed, thus, blocking the method return until it is finalized
Adds the specified key value pair to the cache . If the added key already exists the existent value is replaced . It must be noted that if a new element is added and the is reached a CleanUp operation would be executed thus blocking the method return until it is finalized
public void Add(K key, V value)
        {
            lock (lockObj)
            {
                KeyValuePair<LinkedListNode<K>,V> item;
                if (cache.TryGetValue(key, out item))
                {
                    fetchOrder.Remove(item.Key);
                }
                fetchOrder.AddFirst(key);
                if (cache.Count >= CacheMaximumSize)
                {
                    Clean();
                }
            }
        }
public void Add ( K key , V value ) { lock ( lockObj ) { KeyValuePair < LinkedListNode < K > , V > item ; if ( cache . TryGetValue ( key , out item ) ) { fetchOrder . Remove ( item . Key ) ; } fetchOrder . AddFirst ( key ) ; if ( cache . Count >= CacheMaximumSize ) { Clean ( ) ; } } }
Adds the specified key value pair to the cache.
Adds the specified key value pair to the cache .
key
K
None
value
V
None