/// <summary> /// Queue a seal operation in the background. Attempts to upload all content to VSTS before updating the metadata as backed. /// Lost races will be ignored and any failures will be logged and reported on shutdown. /// </summary> protected void SealInTheBackground( Context context, StrongFingerprint strongFingerprint, ContentHashListWithDeterminism contentHashListWithDeterminism) { if (_sealUnbackedContentHashLists) { _taskTracker.Add(Task.Run(() => SealAsync(context, strongFingerprint, contentHashListWithDeterminism))); } }
/// <summary> /// Runs a given redis query and bumps the key expiration in batch mode /// </summary> private async Task <T> RunQueryWithExpiryBump <T>(Context context, string cacheKey, Func <IRedisBatch, Task <T> > redisQuery) { var batch = _dbAdapter.CreateBatchOperation(RedisOperation.RunQueryWithExpiryBump); var addTask = redisQuery(batch).FireAndForgetAndReturnTask(context); // Return value is not used, but task tracker ensures that no unhandled exception is thrown during garbage collection _taskTracker.Add(batch.KeyExpireAsync(cacheKey, DateTime.UtcNow.Add(CacheKeyBumpTime))); await _dbAdapter.ExecuteBatchOperationAsync(context, batch, CancellationToken.None).IgnoreFailure(); return(await addTask); }
/// <inheritdoc /> public void Dispose() { lock (_lock) { if (!_disposed) { if (_unpinAsync != null) { _taskTracker.Add(_unpinAsync(_pinnedHashes)); } _unpinAction?.Invoke(_pinnedHashes); _disposed = true; } } }