feat(dal,api): IMatchingStatusService - управление статусами matcher`a. Отображение статусов в АПИ, нельзя повторно из апи отправить задание мэтчеру если сейчас идет matching
This commit is contained in:
@@ -1,63 +0,0 @@
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Cache.Models;
|
||||
using PARR.DAL.Cache.Services.Base;
|
||||
|
||||
namespace PARR.DAL.Cache.Services
|
||||
{
|
||||
internal class CacheMatchingStatusService : ICacheMatchingStatusService
|
||||
{
|
||||
private readonly IRedisCacheService redisCacheService;
|
||||
|
||||
public CacheMatchingStatusService(IRedisCacheService redisCacheService)
|
||||
{
|
||||
this.redisCacheService = redisCacheService;
|
||||
}
|
||||
|
||||
public async Task DeleteCacheAsync(Guid id, SyncTaskEntityTypeEnum type)
|
||||
{
|
||||
var key = GetKey(id, type);
|
||||
|
||||
await redisCacheService.DeleteCachedDataAsync(key);
|
||||
}
|
||||
|
||||
|
||||
public async Task<MatchingStatus?> GetDataAsync(Guid id, SyncTaskEntityTypeEnum type)
|
||||
{
|
||||
var key = GetKey(id, type);
|
||||
|
||||
return await redisCacheService.GetCachedDataAsync<MatchingStatus>(key);
|
||||
}
|
||||
|
||||
|
||||
public async Task SetCacheAsync(Guid id, SyncTaskEntityTypeEnum type, MatchingStatusDto data, TimeSpan cacheDuration)
|
||||
{
|
||||
var key = GetKey(id, type);
|
||||
|
||||
await redisCacheService.SetCachedDataAsync(key, data, cacheDuration);
|
||||
}
|
||||
|
||||
|
||||
private string GetKey(Guid id, SyncTaskEntityTypeEnum type)
|
||||
{
|
||||
var typeStr = "";
|
||||
switch (type)
|
||||
{
|
||||
case SyncTaskEntityTypeEnum.Job:
|
||||
typeStr = "j";
|
||||
break;
|
||||
case SyncTaskEntityTypeEnum.JobGroup:
|
||||
typeStr = "g";
|
||||
break;
|
||||
case SyncTaskEntityTypeEnum.Template:
|
||||
typeStr = "t";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return redisCacheService.GetKey(new string[] { "ms", typeStr, id.ToString() });
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Cache.Models;
|
||||
|
||||
namespace PARR.DAL.Cache.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Сервис - статус matching`a
|
||||
/// </summary>
|
||||
public interface ICacheMatchingStatusService
|
||||
{
|
||||
Task<MatchingStatus?> GetDataAsync(Guid id, SyncTaskEntityTypeEnum type);
|
||||
|
||||
Task SetCacheAsync(Guid id, SyncTaskEntityTypeEnum type, MatchingStatusDto data, TimeSpan cacheDuration);
|
||||
|
||||
Task DeleteCacheAsync(Guid id, SyncTaskEntityTypeEnum type);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user