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