😎修改验证码缓存过期时间使用验证码配置的

This commit is contained in:
zuohuaijun 2024-12-24 13:00:07 +08:00
parent 91b9e35146
commit ae6e183054

View File

@ -42,8 +42,8 @@ public class CaptchaDistributedCache : IDistributedCache
public void Set(string key, byte[] value, DistributedCacheEntryOptions options)
{
var timeSpan = options.AbsoluteExpirationRelativeToNow != null ? options.AbsoluteExpirationRelativeToNow.Value : TimeSpan.FromMinutes(1);
_cacheProvider.Cache.Set(GetKey(key), value, timeSpan);
TimeSpan timeDifference = options.AbsoluteExpiration.Value.Subtract(DateTimeOffset.Now);
_cacheProvider.Cache.Set(GetKey(key), value, (int)timeDifference.TotalSeconds);
}
public Task SetAsync(string key, byte[] value, DistributedCacheEntryOptions options, CancellationToken token = default)