• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

loresoft / MediatR.CommandQuery / 11937278774

20 Nov 2024 04:10PM UTC coverage: 59.17% (-0.1%) from 59.302%
11937278774

push

github

pwelter34
make HybridCache optional

389 of 745 branches covered (52.21%)

Branch coverage included in aggregate %.

0 of 6 new or added lines in 2 files covered. (0.0%)

1 existing line in 1 file now uncovered.

1208 of 1954 relevant lines covered (61.82%)

19.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/MediatR.CommandQuery/Behaviors/HybridCacheExpireBehavior.cs
1
using MediatR.CommandQuery.Definitions;
2

3
using Microsoft.Extensions.Caching.Hybrid;
4
using Microsoft.Extensions.Logging;
5

6
namespace MediatR.CommandQuery.Behaviors;
7

8
public partial class HybridCacheExpireBehavior<TRequest, TResponse> : PipelineBehaviorBase<TRequest, TResponse>
9
    where TRequest : class, IRequest<TResponse>
10
{
11
    private readonly HybridCache _hybridCache;
12

13
    public HybridCacheExpireBehavior(
14
        ILoggerFactory loggerFactory,
15
        HybridCache hybridCache)
16
        : base(loggerFactory)
×
17
    {
18
        ArgumentNullException.ThrowIfNull(hybridCache);
×
19

20
        _hybridCache = hybridCache;
×
21
    }
×
22

23
    protected override async Task<TResponse> Process(
24
        TRequest request,
25
        RequestHandlerDelegate<TResponse> next,
26
        CancellationToken cancellationToken)
27
    {
28
        ArgumentNullException.ThrowIfNull(request);
×
29
        ArgumentNullException.ThrowIfNull(next);
×
30

31
        var response = await next().ConfigureAwait(false);
×
32

33
        // expire cache
34
        if (request is not ICacheExpire cacheRequest)
×
35
            return response;
×
36

37
        var cacheTag = cacheRequest.GetCacheTag();
×
38
        if (!string.IsNullOrEmpty(cacheTag))
×
39
            await _hybridCache.RemoveByTagAsync(cacheTag, cancellationToken).ConfigureAwait(false);
×
40

41
        return response;
×
42
    }
×
43
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc