private EvictionStrategyHandler GetCurrentEvictionStrategy(int startIDX,
                                                                   CacheItem <TValue, TKey>[] d, out ReplacementArgs <TValue, TKey> args)
        {
            args = null;
            switch (Config.Strategy)
            {
            case ReplacementStrategy.LRU: return(EvictionStrategyLRU);

            case ReplacementStrategy.MRU: return(EvictionStrategyMRU);

            default: {
                args = new ReplacementArgs <TValue, TKey>(startIDX, startIDX + Config.ItemsPerSet - 1, idx => { return(d[idx]); });
                return(EvictionStrategyCustom);
            }
            }
        }
 private bool EvictionStrategyCustom(CacheItem <TValue, TKey> currentCandidate,
                                     CacheItem <TValue, TKey> testItem, ReplacementArgs <TValue, TKey> args, ref bool candidateFound)
 {
     if (m_replacementHandler != null && args != null && (args.CommitItemWithIndexForEvicton < 0))
     {
         m_replacementHandler(args);
         int committedITDX = args.CommitItemWithIndexForEvicton;
         if (committedITDX > -1 && committedITDX >= args.StartIndex && committedITDX <= args.EndIndex)
         {
             candidateFound = true;
             return(true);
         }
         else
         {
             args.CommitItemWithIndexForEvicton = -1;  // reset in case custom provider supplied invalid index value
         }
     }
     return(false);
 }
 /// <summary>
 /// MRU eviction strategy handler
 /// </summary>
 /// <param name="currentCandidate"></param>
 /// <param name="testItem"></param>
 /// <param name="args"></param>
 /// <param name="candidateFound"></param>
 /// <returns></returns>
 private bool EvictionStrategyMRU(CacheItem <TValue, TKey> currentCandidate,
                                  CacheItem <TValue, TKey> testItem, ReplacementArgs <TValue, TKey> args, ref bool candidateFound) => ((currentCandidate == null) || currentCandidate.TimeStamp < testItem.TimeStamp);