more redis fixes

This commit is contained in:
Stanley Dimant
2022-09-13 12:23:19 +02:00
parent 56728d1fba
commit 54499f42a4
2 changed files with 7 additions and 7 deletions

View File

@@ -17,17 +17,15 @@ public class SystemInfoService : IHostedService, IDisposable
{ {
private readonly MareMetrics _mareMetrics; private readonly MareMetrics _mareMetrics;
private readonly IClientIdentificationService clientIdentService; private readonly IClientIdentificationService clientIdentService;
private readonly IServiceProvider _services;
private readonly ILogger<SystemInfoService> _logger; private readonly ILogger<SystemInfoService> _logger;
private readonly IHubContext<MareHub> _hubContext; private readonly IHubContext<MareHub> _hubContext;
private Timer _timer; private Timer _timer;
public SystemInfoDto SystemInfoDto { get; private set; } = new(); public SystemInfoDto SystemInfoDto { get; private set; } = new();
public SystemInfoService(MareMetrics mareMetrics, IClientIdentificationService clientIdentService, IServiceProvider services, ILogger<SystemInfoService> logger, IHubContext<MareHub> hubContext) public SystemInfoService(MareMetrics mareMetrics, IClientIdentificationService clientIdentService, ILogger<SystemInfoService> logger, IHubContext<MareHub> hubContext)
{ {
_mareMetrics = mareMetrics; _mareMetrics = mareMetrics;
this.clientIdentService = clientIdentService; this.clientIdentService = clientIdentService;
_services = services;
_logger = logger; _logger = logger;
_hubContext = hubContext; _hubContext = hubContext;
} }
@@ -53,9 +51,6 @@ public class SystemInfoService : IHostedService, IDisposable
var secondaryServer = Environment.GetEnvironmentVariable("SECONDARY_SERVER"); var secondaryServer = Environment.GetEnvironmentVariable("SECONDARY_SERVER");
if (string.IsNullOrEmpty(secondaryServer) || secondaryServer == "0") if (string.IsNullOrEmpty(secondaryServer) || secondaryServer == "0")
{ {
using var scope = _services.CreateScope();
using var db = scope.ServiceProvider.GetService<MareDbContext>()!;
SystemInfoDto = new SystemInfoDto() SystemInfoDto = new SystemInfoDto()
{ {
CacheUsage = 0, CacheUsage = 0,

View File

@@ -54,7 +54,12 @@ public class DistributedClientIdentificationService : BaseClientIdentificationSe
public override void MarkUserOnline(string uid, string charaIdent) public override void MarkUserOnline(string uid, string charaIdent)
{ {
base.MarkUserOnline(uid, charaIdent); base.MarkUserOnline(uid, charaIdent);
distributedCache.Set(RedisPrefix + uid, Encoding.UTF8.GetBytes(charaIdent)); distributedCache.Set(RedisPrefix + uid, Encoding.UTF8.GetBytes(charaIdent), new DistributedCacheEntryOptions()
{
AbsoluteExpiration = DateTimeOffset.MaxValue,
AbsoluteExpirationRelativeToNow = TimeSpan.MaxValue,
SlidingExpiration = TimeSpan.MaxValue,
});
} }
public override Task StopAsync(CancellationToken cancellationToken) public override Task StopAsync(CancellationToken cancellationToken)