Example #1
0
        // Cache_Free
        //
        // Frees the memory and removes it from the LRU list
        private void Free(CacheUser c)
        {
            if (c.data == null)
            {
                Utilities.Error("Cache_Free: not allocated");
            }

            var entry = ( CacheEntry )c;

            entry.Remove( );
        }
Example #2
0
        // Cache_Check
        /// <summary>
        /// Cache_Check
        /// Returns value of c.data if still cached or null
        /// </summary>
        public Object Check(CacheUser c)
        {
            var cs = ( CacheEntry )c;

            if (cs == null || cs.data == null)
            {
                return(null);
            }

            // move to head of LRU
            cs.RemoveFromLRU( );
            cs.LRUInstertAfter(Head);

            return(cs.data);
        }