ICacheService.cs 750 B

12345678910111213141516
  1. namespace Application.Abstractions.Cache;
  2. public interface ICacheService
  3. {
  4. Task<T?> GetAsync<T>(string key, CancellationToken ct = default);
  5. Task SetAsync<T>(string key, T value, CancellationToken ct = default);
  6. Task SetAsync<T>(string key, T value, TimeSpan expiry, CancellationToken ct = default);
  7. Task RemoveAsync(string key, CancellationToken ct = default);
  8. Task RemoveByPrefixAsync(string prefix, CancellationToken ct = default);
  9. /// <summary>
  10. /// 분산 원자적 잠금 (SET NX EX). 키가 이미 있으면 false, 없으면 생성 후 true 반환.
  11. /// 쿨다운, 중복 처리 방지 등에 사용.
  12. /// </summary>
  13. Task<bool> TryLockAsync(string key, TimeSpan expiry, CancellationToken ct = default);
  14. }