@@ -29,16 +29,20 @@ public class PostgreSqlStorageOptions
29
29
private TimeSpan _invisibilityTimeout ;
30
30
private TimeSpan _distributedLockTimeout ;
31
31
private TimeSpan _transactionSerializationTimeout ;
32
+ private TimeSpan _jobExpirationCheckInterval ;
33
+ private int _deleteExpiredBatchSize ;
32
34
33
35
public PostgreSqlStorageOptions ( )
34
36
{
35
37
QueuePollInterval = TimeSpan . FromSeconds ( 15 ) ;
36
38
InvisibilityTimeout = TimeSpan . FromMinutes ( 30 ) ;
37
39
DistributedLockTimeout = TimeSpan . FromMinutes ( 10 ) ;
38
40
TransactionSynchronisationTimeout = TimeSpan . FromMilliseconds ( 500 ) ;
41
+ JobExpirationCheckInterval = TimeSpan . FromHours ( 1 ) ;
39
42
SchemaName = "hangfire" ;
40
43
UseNativeDatabaseTransactions = true ;
41
44
PrepareSchemaIfNecessary = true ;
45
+ DeleteExpiredBatchSize = 1000 ;
42
46
}
43
47
44
48
public TimeSpan QueuePollInterval
@@ -81,7 +85,30 @@ public TimeSpan TransactionSynchronisationTimeout
81
85
}
82
86
}
83
87
84
- public bool UseNativeDatabaseTransactions { get ; set ; }
88
+ public TimeSpan JobExpirationCheckInterval
89
+ {
90
+ get => _jobExpirationCheckInterval ;
91
+ set
92
+ {
93
+ ThrowIfValueIsNotPositive ( value , nameof ( JobExpirationCheckInterval ) ) ;
94
+ _jobExpirationCheckInterval = value ;
95
+ }
96
+ }
97
+
98
+ /// <summary>
99
+ /// Gets or sets the number of records deleted in a single batch in expiration manager
100
+ /// </summary>
101
+ public int DeleteExpiredBatchSize
102
+ {
103
+ get => _deleteExpiredBatchSize ;
104
+ set
105
+ {
106
+ ThrowIfValueIsNotPositive ( value , nameof ( DeleteExpiredBatchSize ) ) ;
107
+ _deleteExpiredBatchSize = value ;
108
+ }
109
+ }
110
+
111
+ public bool UseNativeDatabaseTransactions { get ; set ; }
85
112
public bool PrepareSchemaIfNecessary { get ; set ; }
86
113
public string SchemaName { get ; set ; }
87
114
public bool EnableTransactionScopeEnlistment { get ; set ; }
@@ -99,5 +126,11 @@ private static void ThrowIfValueIsNotPositive(TimeSpan value, string fieldName)
99
126
throw new ArgumentException ( message , nameof ( value ) ) ;
100
127
}
101
128
}
129
+
130
+ private static void ThrowIfValueIsNotPositive ( int value , string fieldName )
131
+ {
132
+ if ( value <= 0 )
133
+ throw new ArgumentException ( $ "The { fieldName } property value should be positive. Given: { value } .") ;
134
+ }
102
135
}
103
136
}
0 commit comments