Handler.cs 597 B

12345678910111213141516171819202122
  1. using Application.Abstractions.Cache;
  2. using Application.Abstractions.Messaging;
  3. using SharedKernel.Results;
  4. namespace Application.Features.Admin.Cache.ClearCache;
  5. internal sealed class Handler(ICacheService cache) : ICommandHandler<Command, Result>
  6. {
  7. public async Task<Result> Handle(Command request, CancellationToken ct)
  8. {
  9. if (string.IsNullOrEmpty(request.Prefix))
  10. {
  11. await cache.RemoveByPrefixAsync("", ct);
  12. }
  13. else
  14. {
  15. await cache.RemoveByPrefixAsync(request.Prefix, ct);
  16. }
  17. return Result.Success();
  18. }
  19. }