コード例 #1
0
        /// <summary>
        /// Given a cached message, indicates whether it should be purged from the cache.
        /// </summary>
        /// <param name="cachedMessage">The cached message.</param>
        /// <param name="newestCachedMessage">The newest cached message.</param>
        /// <param name="nowUtc">The current time (UTC).</param>
        /// <returns><see langword="true" /> if the message should be purged, <see langword="false" /> otherwise.</returns>
        protected virtual bool ShouldPurge(ref CachedMessage cachedMessage, ref CachedMessage 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.ShouldPurgeFromTime(timeInCache, relativeAge));
        }