Эх сурвалжийг харах

remove ConnectorStatus cache

Robert 1 жил өмнө
parent
commit
ad9c75dd84

+ 11 - 11
EVCB_OCPP.WSServer/Service/MainDbService.cs

@@ -162,24 +162,24 @@ public class MainDbService : IMainDbService
 
         await db.SaveChangesAsync();
 
-        memoryCache.Set(
-            string.Format(ChargeBoxConnectorIdMemCacheKeyFromat, ChargeBoxId, ConnectorId)
-            , _currentStatus, TimeSpan.FromHours(12));
+        //memoryCache.Set(
+        //    string.Format(ChargeBoxConnectorIdMemCacheKeyFromat, ChargeBoxId, ConnectorId)
+        //    , _currentStatus, TimeSpan.FromHours(12));
     }
 
     public async ValueTask<ConnectorStatus> GetConnectorStatus(string ChargeBoxId, int ConnectorId)
     {
-        var key = string.Format(ChargeBoxConnectorIdMemCacheKeyFromat, ChargeBoxId, ConnectorId);
-        if (memoryCache.TryGetValue<ConnectorStatus>(key, out var status))
-        {
-            return status;
-        }
+        //var key = string.Format(ChargeBoxConnectorIdMemCacheKeyFromat, ChargeBoxId, ConnectorId);
+        //if (memoryCache.TryGetValue<ConnectorStatus>(key, out var status))
+        //{
+        //    return status;
+        //}
 
         using var db = await contextFactory.CreateDbContextAsync();
         var statusFromDb = await db.ConnectorStatuses.Where(x => x.ChargeBoxId == ChargeBoxId
                             && x.ConnectorId == ConnectorId).AsNoTracking().FirstOrDefaultAsync();
 
-        memoryCache.Set(key, statusFromDb, TimeSpan.FromHours(12));
+        //memoryCache.Set(key, statusFromDb, TimeSpan.FromHours(12));
         return statusFromDb;
     }
 
@@ -189,8 +189,8 @@ public class MainDbService : IMainDbService
         //await UpdateConnectorStatusEF(Id, Status);
         await UpdateConnectorStatusDapper(Id, Status);
 
-        var key = string.Format(ChargeBoxConnectorIdMemCacheKeyFromat, Status.ChargeBoxId, Status.ConnectorId);
-        memoryCache.Set(key, Status, TimeSpan.FromHours(12));
+        //var key = string.Format(ChargeBoxConnectorIdMemCacheKeyFromat, Status.ChargeBoxId, Status.ConnectorId);
+        //memoryCache.Set(key, Status, TimeSpan.FromHours(12));
         return;
     }