✨ Setup etcd helper and magic onion
This commit is contained in:
@@ -84,16 +84,16 @@ public class AccountEventService(
|
||||
foreach (var userId in userIds)
|
||||
{
|
||||
var cacheKey = $"{StatusCacheKey}{userId}";
|
||||
// var cachedStatus = await cache.GetAsync<Status>(cacheKey);
|
||||
// if (cachedStatus != null)
|
||||
// {
|
||||
// cachedStatus.IsOnline = !cachedStatus.IsInvisible && ws.GetAccountIsConnected(userId);
|
||||
// results[userId] = cachedStatus;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
cacheMissUserIds.Add(userId);
|
||||
// }
|
||||
var cachedStatus = await cache.GetAsync<Status>(cacheKey);
|
||||
if (cachedStatus != null)
|
||||
{
|
||||
cachedStatus.IsOnline = !cachedStatus.IsInvisible /*&& ws.GetAccountIsConnected(userId)*/;
|
||||
results[userId] = cachedStatus;
|
||||
}
|
||||
else
|
||||
{
|
||||
cacheMissUserIds.Add(userId);
|
||||
}
|
||||
}
|
||||
|
||||
if (cacheMissUserIds.Any())
|
||||
@@ -115,7 +115,7 @@ public class AccountEventService(
|
||||
status.IsOnline = !status.IsInvisible && isOnline;
|
||||
results[status.AccountId] = status;
|
||||
var cacheKey = $"{StatusCacheKey}{status.AccountId}";
|
||||
// await cache.SetAsync(cacheKey, status, TimeSpan.FromMinutes(5));
|
||||
await cache.SetAsync(cacheKey, status, TimeSpan.FromMinutes(5));
|
||||
foundUserIds.Add(status.AccountId);
|
||||
}
|
||||
|
||||
@@ -170,12 +170,12 @@ public class AccountEventService(
|
||||
public async Task<bool> CheckInDailyDoAskCaptcha(Shared.Models.Account user)
|
||||
{
|
||||
var cacheKey = $"{CaptchaCacheKey}{user.Id}";
|
||||
// var needsCaptcha = await cache.GetAsync<bool?>(cacheKey);
|
||||
// if (needsCaptcha is not null)
|
||||
// return needsCaptcha!.Value;
|
||||
var needsCaptcha = await cache.GetAsync<bool?>(cacheKey);
|
||||
if (needsCaptcha is not null)
|
||||
return needsCaptcha!.Value;
|
||||
|
||||
var result = Random.Next(100) < CaptchaProbabilityPercent;
|
||||
// await cache.SetAsync(cacheKey, result, TimeSpan.FromHours(24));
|
||||
await cache.SetAsync(cacheKey, result, TimeSpan.FromHours(24));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user