feat(core): UnitService - работа с кэш
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
@@ -7,7 +8,9 @@ using PARR.API.Services.Interfaces;
|
||||
using PARR.API.Settings;
|
||||
using PARR.Core.Common.Interfaces;
|
||||
using PARR.Core.Repositories.Interfaces;
|
||||
using PARR.Core.Repositories.Interfaces.Unit;
|
||||
using PARR.Core.Services.NextRunServices;
|
||||
using PARR.Core.Services.UnitService.Interfaces;
|
||||
using PARR.Core.Services.Workload.Implementations;
|
||||
using PARR.Domain.Cache;
|
||||
|
||||
@@ -22,6 +25,8 @@ namespace PARR.API.Controllers.V1
|
||||
private readonly ITemplateRepository templateService;
|
||||
private readonly WorkloadCacheService workloadCacheService;
|
||||
private readonly ILogger<TestController> logger;
|
||||
private readonly IUnitService unitService;
|
||||
private readonly IUnitRepository unitRepository;
|
||||
|
||||
public TestController(
|
||||
IClientService clientService,
|
||||
@@ -30,7 +35,9 @@ namespace PARR.API.Controllers.V1
|
||||
ITemplateRepository templateService,
|
||||
MqSettings mqSettings,
|
||||
WorkloadCacheService workloadCacheService,
|
||||
ILogger<TestController> logger
|
||||
ILogger<TestController> logger,
|
||||
IUnitService unitService,
|
||||
IUnitRepository unitRepository
|
||||
)
|
||||
{
|
||||
this.clientService = clientService;
|
||||
@@ -39,6 +46,8 @@ namespace PARR.API.Controllers.V1
|
||||
this.templateService = templateService;
|
||||
this.workloadCacheService = workloadCacheService;
|
||||
this.logger = logger;
|
||||
this.unitService = unitService;
|
||||
this.unitRepository = unitRepository;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,24 +89,38 @@ namespace PARR.API.Controllers.V1
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost(ApiRoutes.Test.CreateCache)]
|
||||
public async Task<IActionResult> CreateCache()
|
||||
public async Task<IActionResult> CreateCache([FromBody] Guid unitId)
|
||||
{
|
||||
#region Test bucket id
|
||||
var units = await unitRepository.Get().Take(100).Select(t => t.Id).ToListAsync();
|
||||
var listData = await unitService.GetWithCachingAsync(units);
|
||||
//foreach(var unit in units)
|
||||
//{
|
||||
// //поштучно
|
||||
// var unitTtt = await unitService.GetWithCachingAsync(unit);
|
||||
//}
|
||||
|
||||
var idList = new List<Guid>();
|
||||
return Ok();
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
idList.Add( Guid.NewGuid());
|
||||
|
||||
foreach(var id in idList.OrderBy(t => t))
|
||||
{
|
||||
var key = CacheKeys.Unit.UnitHashWithBucket(id);
|
||||
var redisKey = redisCacheService.GetKey(key);
|
||||
//var unit = await unitService.GetWithCachingAsync(unitId);
|
||||
|
||||
logger.LogDebug("Id: {Id}, key: '{Key}', redis key: '{RedisKey}'", id, key, redisKey);
|
||||
}
|
||||
//return Ok(unit);
|
||||
|
||||
#endregion
|
||||
//#region Test bucket id
|
||||
|
||||
//var idList = new List<Guid>();
|
||||
|
||||
//for (int i = 0; i < 100; i++)
|
||||
// idList.Add( Guid.NewGuid());
|
||||
|
||||
//foreach(var id in idList.OrderBy(t => t))
|
||||
//{
|
||||
// var key = CacheKeys.Unit.UnitHashWithBucket(id);
|
||||
// var redisKey = redisCacheService.GetKey(key);
|
||||
|
||||
// logger.LogDebug("Id: {Id}, key: '{Key}', redis key: '{RedisKey}'", id, key, redisKey);
|
||||
//}
|
||||
|
||||
//#endregion
|
||||
|
||||
|
||||
// var aaa = await workloadCacheService.GetTemplateReportDataAsync();
|
||||
|
||||
Reference in New Issue
Block a user