Class DistributedLockTimeoutExtensions
Extension methods for expressing the timeout a distributed lock waits for as a database command timeout.
Inheritance
Namespace: Umbraco.Cms.Infrastructure.Persistence
Assembly: Umbraco.Infrastructure.dll
Syntax
public static class DistributedLockTimeoutExtensions
Methods
View SourceToLockCommandTimeoutSeconds(TimeSpan)
Converts the timeout a distributed lock waits for to the whole number of seconds that the statement obtaining it should run under.
Declaration
public static int ToLockCommandTimeoutSeconds(this TimeSpan lockTimeout)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | lockTimeout | The timeout the lock waits for. |
Returns
| Type | Description |
|---|---|
| int | The command timeout in whole seconds. |
Remarks
Allows a margin on top of the lock timeout, so that a mechanism able to report a lock timeout of its own gets to do so before the client abandons the command. Rounds up, so that a sub-second timeout cannot become zero seconds - which providers read as no limit at all.
The result is a function of the lock's own wait alone, deliberately independent of any ambient command timeout: a lock statement reads or writes a single row, so a longer configured timeout buys it nothing, and a shorter one would stop it waiting as asked.