@@ -30,6 +30,7 @@ public class PostgreSqlStorageOptions
30
30
private TimeSpan _distributedLockTimeout ;
31
31
private TimeSpan _transactionSerializationTimeout ;
32
32
private TimeSpan _jobExpirationCheckInterval ;
33
+ private int _deleteExpiredBatchSize ;
33
34
34
35
public PostgreSqlStorageOptions ( )
35
36
{
@@ -41,6 +42,7 @@ public PostgreSqlStorageOptions()
41
42
SchemaName = "hangfire" ;
42
43
UseNativeDatabaseTransactions = true ;
43
44
PrepareSchemaIfNecessary = true ;
45
+ DeleteExpiredBatchSize = 1000 ;
44
46
}
45
47
46
48
public TimeSpan QueuePollInterval
@@ -93,7 +95,20 @@ public TimeSpan JobExpirationCheckInterval
93
95
}
94
96
}
95
97
96
- public bool UseNativeDatabaseTransactions { get ; set ; }
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 ; }
97
112
public bool PrepareSchemaIfNecessary { get ; set ; }
98
113
public string SchemaName { get ; set ; }
99
114
public bool EnableTransactionScopeEnlistment { get ; set ; }
@@ -111,5 +126,11 @@ private static void ThrowIfValueIsNotPositive(TimeSpan value, string fieldName)
111
126
throw new ArgumentException ( message , nameof ( value ) ) ;
112
127
}
113
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
+ }
114
135
}
115
136
}
0 commit comments