forked from xiongyuxing/tiku-backend.net
17 lines
546 B
C#
17 lines
546 B
C#
namespace Tiku.Application.Security;
|
|
|
|
public sealed record DistributedRateLimitBucket(string Key, int PermitLimit, TimeSpan Window);
|
|
|
|
public sealed record DistributedRateLimitResult(bool Allowed, TimeSpan? RetryAfter = null);
|
|
|
|
public interface IRedisSecurityStore
|
|
{
|
|
bool IsConfigured { get; }
|
|
|
|
Task<DistributedRateLimitResult> ConsumeAsync(
|
|
IReadOnlyCollection<DistributedRateLimitBucket> buckets,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
Task<bool> PingAsync(CancellationToken cancellationToken = default);
|
|
}
|