Cleanup on aisle DbCacheService
This commit is contained in:
parent
8068f6965d
commit
d32686a000
@ -109,7 +109,7 @@ public class InventoryController : Controller {
|
|||||||
return lst;
|
return lst;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inventory/Delete => Décrémenter un produit.
|
// Inventory/Delete => Décrémenter un produit. Va aller chercher directement dans la BD.
|
||||||
[EnableCors("_myAllowSpecificOrigins")]
|
[EnableCors("_myAllowSpecificOrigins")]
|
||||||
[HttpDelete(Name = "Inventory")]
|
[HttpDelete(Name = "Inventory")]
|
||||||
public ActionResult<int> Delete(int? id) {
|
public ActionResult<int> Delete(int? id) {
|
||||||
@ -139,6 +139,7 @@ public class InventoryController : Controller {
|
|||||||
_logger.LogError(8, e.Message);
|
_logger.LogError(8, e.Message);
|
||||||
return BadRequest();
|
return BadRequest();
|
||||||
}
|
}
|
||||||
|
_cache.askForRefresh();
|
||||||
return rid;
|
return rid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ namespace GrossesMitainesAPI.Services {
|
|||||||
public class DatabaseCacheService {
|
public class DatabaseCacheService {
|
||||||
private readonly IServiceScopeFactory _contextFactory; // https://entityframeworkcore.com/knowledge-base/51939451/how-to-use-a-database-context-in-a-singleton-service-
|
private readonly IServiceScopeFactory _contextFactory; // https://entityframeworkcore.com/knowledge-base/51939451/how-to-use-a-database-context-in-a-singleton-service-
|
||||||
private readonly ILogger<DatabaseCacheService> _logger;
|
private readonly ILogger<DatabaseCacheService> _logger;
|
||||||
|
|
||||||
private Product[] _cache = new Product[1];
|
private Product[] _cache = new Product[1];
|
||||||
private bool _ok = false, _needUpd = true;
|
private bool _ok = false, _needUpd = true;
|
||||||
private PeriodicTimer _timer = new PeriodicTimer(TimeSpan.FromSeconds(10));
|
private PeriodicTimer _timer = new PeriodicTimer(TimeSpan.FromSeconds(10));
|
||||||
@ -25,7 +26,6 @@ namespace GrossesMitainesAPI.Services {
|
|||||||
_needUpd = !_ok;
|
_needUpd = !_ok;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateCache() {
|
private bool UpdateCache() {
|
||||||
try {
|
try {
|
||||||
Product[] prods;
|
Product[] prods;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user