Skip to content

Instantly share code, notes, and snippets.

@anderly
anderly / CacheService.cs
Last active January 27, 2024 20:54
MediatR Caching Pipeline Behavior
public class CacheService : ICache
{
private readonly string _keyPrefix;
private readonly IDistributedCache _cache;
private readonly IConfiguration _config;
public CacheService(IDistributedCache cache, IConfiguration config)
{
_cache = cache;
_config = config;
@henkmollema
henkmollema / RetryPolicyBehavior.cs
Last active August 7, 2023 19:04
Transient failure handling for MediatR using Polly
using System;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Microsoft.Extensions.Logging;
using Polly;
namespace Foo.Bar
{