mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2026-04-06 05:54:28 +00:00
Forgot a condition.
This commit is contained in:
@@ -40,15 +40,18 @@ namespace Aaru.Server.Controllers;
|
||||
[Controller]
|
||||
public sealed class UpdateController(DbContext ctx) : ControllerBase
|
||||
{
|
||||
static List<Device>? _deviceDbCacheSingleton;
|
||||
static readonly DateTime _lastCache = DateTime.MinValue;
|
||||
static List<Device>? _deviceDbCacheSingleton;
|
||||
static DateTime _lastCache = DateTime.MinValue;
|
||||
|
||||
IEnumerable<Device> DeviceDbCache
|
||||
{
|
||||
get
|
||||
{
|
||||
if(_deviceDbCacheSingleton is null || DateTime.UtcNow - _lastCache > TimeSpan.FromHours(1))
|
||||
_deviceDbCacheSingleton = ctx.Devices.ToList();
|
||||
if(_deviceDbCacheSingleton is not null && DateTime.UtcNow - _lastCache <= TimeSpan.FromHours(1))
|
||||
return _deviceDbCacheSingleton;
|
||||
|
||||
_deviceDbCacheSingleton = ctx.Devices.ToList();
|
||||
_lastCache = DateTime.UtcNow;
|
||||
|
||||
return _deviceDbCacheSingleton;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user