Skip to content

Commit eea90e7

Browse files
committed
Updates the throttle timeout to be part of the options
1 parent c7f8d42 commit eea90e7

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/Umbraco.Core/Sync/DatabaseServerMessenger.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ public DatabaseServerMessenger(ApplicationContext appContext, bool enableDistCal
4848
private readonly object _lock = new object();
4949
private int _lastId = -1;
5050
private volatile bool _syncing = false;
51-
//this ensures that only one thread can possibly check for sync operations every 5 seconds
52-
private const int SyncTimeFrameSeconds = 5;
5351
private long _lastUtcTicks;
5452

5553
/// <summary>
@@ -118,7 +116,7 @@ internal void Sync()
118116
{
119117

120118
//don't process, this is not in the timeframe - we don't want to check the db every request, only once if it's been at least 5 seconds.
121-
if (TimeSpan.FromTicks(DateTime.UtcNow.Ticks).TotalSeconds - TimeSpan.FromTicks(_lastUtcTicks).TotalSeconds <= SyncTimeFrameSeconds)
119+
if (TimeSpan.FromTicks(DateTime.UtcNow.Ticks).TotalSeconds - TimeSpan.FromTicks(_lastUtcTicks).TotalSeconds <= _options.ThrottleSeconds)
122120
{
123121
//NOTE: Removed logging as it will just keep showing this and people will wonder why.
124122
//LogHelper.Debug<DatabaseServerMessenger>("Skipping distributed sync, not in timeframe");

src/Umbraco.Core/Sync/DatabaseServerMessengerOptions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ internal class DatabaseServerMessengerOptions
55
public DatabaseServerMessengerOptions()
66
{
77
DaysToRetainInstructionRecords = 100;
8+
ThrottleSeconds = 5;
89
}
910

1011
public int DaysToRetainInstructionRecords { get; set; }
12+
13+
/// <summary>
14+
/// The number of seconds to wait between previous sync operations - this ensures that sync operations
15+
/// are not performed too often.
16+
/// </summary>
17+
public int ThrottleSeconds { get; set; }
1118
}
1219
}

0 commit comments

Comments
 (0)