public CreateAndOpenConnection ( ) : |
||
Результат |
/// <summary> /// Run expiration manager to remove outdated records /// </summary> /// <param name="cancellationToken">Cancellation token</param> public void Execute(CancellationToken cancellationToken) { using (HangfireDbContext connection = _storage.CreateAndOpenConnection()) { DateTime now = DateTime.UtcNow; RemoveExpiredRecord(connection.Job, _ => _.ExpireAt, now); RemoveExpiredRecord(connection.StateData.OfType <ExpiringKeyValueDto>(), _ => _.ExpireAt, now); } cancellationToken.WaitHandle.WaitOne(_checkInterval); }
/// <summary> /// Run expiration manager to remove outdated records /// </summary> /// <param name="cancellationToken">Cancellation token</param> public void Execute(CancellationToken cancellationToken) { using (HangfireDbContext connection = _storage.CreateAndOpenConnection()) { DateTime now = DateTime.UtcNow; Logger.DebugFormat("Removing outdated records from table '{0}'...", connection.JobGraph.CollectionNamespace.CollectionName); connection .JobGraph .OfType <ExpiringJobDto>().DeleteMany(Builders <ExpiringJobDto> .Filter.Lt(_ => _.ExpireAt, now)); } cancellationToken.WaitHandle.WaitOne(_checkInterval); }
/// <summary> /// Run expiration manager to remove outdated records /// </summary> /// <param name="cancellationToken">Cancellation token</param> public void Execute(CancellationToken cancellationToken) { using (HangfireDbContext connection = _storage.CreateAndOpenConnection()) { DateTime now = connection.GetServerTimeUtc(); RemoveExpiredRecord(connection.AggregatedCounter, _ => _.ExpireAt, now); RemoveExpiredRecord(connection.Counter, _ => _.ExpireAt, now); RemoveExpiredRecord(connection.Job, _ => _.ExpireAt, now); RemoveExpiredRecord(connection.List, _ => _.ExpireAt, now); RemoveExpiredRecord(connection.Set, _ => _.ExpireAt, now); RemoveExpiredRecord(connection.Hash, _ => _.ExpireAt, now); } cancellationToken.WaitHandle.WaitOne(_checkInterval); }
public void Execute(CancellationToken cancellationToken) { using (HangfireDbContext connection = _storage.CreateAndOpenConnection()) { MongoCollection[] processedTables = { connection.Counter, connection.Job, connection.List, connection.Set, connection.Hash }; DateTime now = connection.GetServerTimeUtc(); foreach (var table in processedTables) { Logger.DebugFormat("Removing outdated records from table '{0}'...", table.Name); table.Remove(Query.LT("ExpireAt", now)); } } cancellationToken.WaitHandle.WaitOne(_checkInterval); }