CachedUntil - Renamed CachedUntilOption to CachedUntilLifetime

This commit is contained in:
dualfroz committed 2026-10-04 18:09:36 +02:00
1 parent 9b8ab6666e
commit d490e07ea2
1 file changed
+7 -7
@@ -73,7 +73,7 @@ namespace NLog.LayoutRenderers.Wrappers
/// <summary> /// <summary>
/// A value indicating when the cached value expires, because the time of the <see cref="LogEventInfo"/> has moved into a new period. /// A value indicating when the cached value expires, because the time of the <see cref="LogEventInfo"/> has moved into a new period.
/// </summary> /// </summary>
public enum CachedUntilOption public enum CachedUntilLifetime
{ {
/// <summary>Never expire the cached value because of the time.</summary> /// <summary>Never expire the cached value because of the time.</summary>
None = 0, None = 0,
@@ -88,7 +88,7 @@ namespace NLog.LayoutRenderers.Wrappers
private string? _renderedCacheKey; private string? _renderedCacheKey;
private DateTime? _cachedValueExpires; private DateTime? _cachedValueExpires;
private TimeSpan? _cachedValueTimeout; private TimeSpan? _cachedValueTimeout;
private CachedUntilOption _cachedUntil; private CachedUntilLifetime _cachedUntil;
/// <summary> /// <summary>
/// Gets or sets a value indicating whether this <see cref="CachedLayoutRendererWrapper"/> is enabled. /// Gets or sets a value indicating whether this <see cref="CachedLayoutRendererWrapper"/> is enabled.
@@ -130,15 +130,15 @@ namespace NLog.LayoutRenderers.Wrappers
/// <summary> /// <summary>
/// Gets or sets when the cached value should expire, so it is reset exactly when the hour or day of the LogEvent TimeStamp changes. Example HourChange will reset the cached value at the start of every hour. /// Gets or sets when the cached value should expire, so it is reset exactly when the hour or day of the LogEvent TimeStamp changes. Example HourChange will reset the cached value at the start of every hour.
/// </summary> /// </summary>
/// <remarks>Default: <see cref="CachedUntilOption.None"/></remarks> /// <remarks>Default: <see cref="CachedUntilLifetime.None"/></remarks>
/// <docgen category='Layout Options' order='10' /> /// <docgen category='Layout Options' order='10' />
public CachedUntilOption CachedUntil public CachedUntilLifetime CachedUntil
{ {
get => _cachedUntil; get => _cachedUntil;
set set
{ {
_cachedUntil = value; _cachedUntil = value;
if (_cachedUntil != CachedUntilOption.None) if (_cachedUntil != CachedUntilLifetime.None)
Cached = true; Cached = true;
} }
} }
@@ -209,9 +209,9 @@ namespace NLog.LayoutRenderers.Wrappers
private DateTime? ResolveCachedValueExpires(DateTime timeStamp) private DateTime? ResolveCachedValueExpires(DateTime timeStamp)
{ {
DateTime? expires = _cachedValueTimeout.HasValue ? timeStamp + _cachedValueTimeout.Value : null; DateTime? expires = _cachedValueTimeout.HasValue ? timeStamp + _cachedValueTimeout.Value : null;
if (_cachedUntil != CachedUntilOption.None) if (_cachedUntil != CachedUntilLifetime.None)
{ {
var periodTicks = _cachedUntil == CachedUntilOption.DayChange ? TimeSpan.TicksPerDay : TimeSpan.TicksPerHour; var periodTicks = _cachedUntil == CachedUntilLifetime.DayChange ? TimeSpan.TicksPerDay : TimeSpan.TicksPerHour;
var periodStart = new DateTime(timeStamp.Ticks - timeStamp.Ticks % periodTicks, timeStamp.Kind); var periodStart = new DateTime(timeStamp.Ticks - timeStamp.Ticks % periodTicks, timeStamp.Kind);
// Inclusive end, so the last period ends at DateTime.MaxValue without overflow // Inclusive end, so the last period ends at DateTime.MaxValue without overflow
var periodEnd = periodStart.AddTicks(periodTicks - 1); var periodEnd = periodStart.AddTicks(periodTicks - 1);