Exemple #1
0
        public void AddOrUpdate(K key, V val)
        {
            lock (Lock)
            {
                if (processUpdate(key, val))
                {
                    return;
                }

                LinkedListNode <CacheLineItem <K, V> > node = new LinkedListNode <CacheLineItem <K, V> >(new CacheLineItem <K, V>(key, val));

                if (CacheMap.Count >= Capacity)
                {
                    var evictedNode = EvictionPolicy.GetItemToEvict(LineList);
                    RemoveFromCache(evictedNode);
                }
                LineList.AddLast(node);
                CacheMap.Add(key, node);
            }
        }