private void Log(eCacheEvent cachingEvent, string key, [CallerMemberName] string callerName = null)
 {
     if (_config.IsAuditingEnabled)
     {
         _auditLog.Add(new CacheAuditLogItem {
             CachingEvent = cachingEvent, CallerFunctionName = callerName, Key = key
         });
     }
     LastCachingEvent = cachingEvent;
 }
        /// <summary>
        /// Helper function that waits for a caching event on this instance
        /// </summary>
        /// <param name="cacheEvent"></param>
        /// <param name="maxWaitMilliseconds"></param>
        /// <returns></returns>
        public async Task <long> WaitForEvent(eCacheEvent cacheEvent, int maxWaitMilliseconds = 20000)
        {
            var sw = Stopwatch.StartNew();

            while (LastCachingEvent != cacheEvent)
            {
                if (sw.ElapsedMilliseconds > maxWaitMilliseconds)
                {
                    throw new Exception(string.Format("Max wait time elapsed waiting for status '{0}', but was '{1}'", cacheEvent, LastCachingEvent));
                }
                await Task.Delay(20);
            }
            return(sw.ElapsedMilliseconds);
        }