// Given a purge cached message, indicates whether it should be purged from the cache private bool ShouldPurge(ref CachedEventHubMessage cachedMessage, ref CachedEventHubMessage newestCachedMessage, DateTime nowUtc) { TimeSpan timeInCache = nowUtc - cachedMessage.DequeueTimeUtc; // age of message relative to the most recent event in the cache. TimeSpan relativeAge = newestCachedMessage.EnqueueTimeUtc - cachedMessage.EnqueueTimeUtc; return(timePurge.ShouldPurgFromTime(timeInCache, relativeAge)); }
/// <summary> /// Given a purge request, indicates if a cached message should be purged from the cache /// </summary> /// <param name="cachedMessage"></param> /// <param name="newestCachedMessage"></param> /// <param name="purgeRequest"></param> /// <param name="nowUtc"></param> /// <returns></returns> public bool ShouldPurge(ref CachedEventHubMessage cachedMessage, ref CachedEventHubMessage newestCachedMessage, IDisposable purgeRequest, DateTime nowUtc) { // if we're purging our current buffer, don't use it any more var purgedResource = (FixedSizeBuffer)purgeRequest; if (currentBuffer != null && currentBuffer.Id == purgedResource.Id) { currentBuffer = null; } TimeSpan timeInCache = nowUtc - cachedMessage.DequeueTimeUtc; // age of message relative to the most recent event in the cache. TimeSpan relativeAge = newestCachedMessage.EnqueueTimeUtc - cachedMessage.EnqueueTimeUtc; return(ShouldPurgeFromResource(ref cachedMessage, purgedResource) || timePurage.ShouldPurgFromTime(timeInCache, relativeAge)); }