Exemplo n.º 1
0
        /// <inheritdoc />
        public async Task <BoolResult> DeleteFingerprintAsync(Context context, StrongFingerprint strongFingerprint)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            try
            {
                _cacheTracer.InvalidateCacheEntryStart(context, strongFingerprint);
                var batch = _dbAdapter.CreateBatchOperation(RedisOperation.DeleteFingerprint);

                // Tasks
                var deleteStrongFingerprint = batch.KeyDeleteAsync(_redisSerializer.ToRedisKey(strongFingerprint)).FireAndForgetAndReturnTask(context);
                var deleteWeakFingerprint   = batch.KeyDeleteAsync(_redisSerializer.ToRedisKey(strongFingerprint.WeakFingerprint)).FireAndForgetAndReturnTask(context);

                await _dbAdapter.ExecuteBatchOperationAsync(context, batch, CancellationToken.None).IgnoreFailure();

                var strongDeleted = await deleteStrongFingerprint;
                var weakDeleted   = await deleteWeakFingerprint;
                if (!strongDeleted || !weakDeleted)
                {
                    _tracer.Warning(context, $"Unable to delete some keys. Strong deleted: {strongDeleted}. Weak deleted: {weakDeleted}.");
                }

                return(BoolResult.Success);
            }
            catch (Exception ex)
            {
                return(new BoolResult(ex));
            }
            finally
            {
                _cacheTracer.InvalidateCacheEntryStop(context, stopwatch.Elapsed);
            }
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public async Task <BoolResult> DeleteFingerprintAsync(Context context, StrongFingerprint strongFingerprint)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            try
            {
                _cacheTracer.InvalidateCacheEntryStart(context, strongFingerprint);
                var batch = _dbAdapter.CreateBatchOperation(RedisOperation.DeleteFingerprint);

                // Tasks
                var deleteStrongFingerprint = batch.KeyDeleteAsync(_redisSerializer.ToRedisKey(strongFingerprint)).FireAndForgetAndReturnTask(context);
                var deleteWeakFingerprint   = batch.KeyDeleteAsync(_redisSerializer.ToRedisKey(strongFingerprint.WeakFingerprint)).FireAndForgetAndReturnTask(context);

                await _dbAdapter.ExecuteBatchOperationAsync(context, batch, CancellationToken.None).IgnoreFailure();

                await Task.WhenAll(deleteStrongFingerprint, deleteWeakFingerprint);

                return(BoolResult.Success);
            }
            catch (Exception ex)
            {
                return(new BoolResult(ex));
            }
            finally
            {
                _cacheTracer.InvalidateCacheEntryStop(context, stopwatch.Elapsed);
            }
        }