From 3205c1db8e5300d20dfe0dc29820cba1fe71e477 Mon Sep 17 00:00:00 2001 From: Mikhail Trubnikov Date: Thu, 15 Jan 2026 15:46:50 +1000 Subject: [PATCH] =?UTF-8?q?feat(dal):=20CacheMatchigStatusService=20=D1=80?= =?UTF-8?q?=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/CacheMatchingStatusService.cs | 52 +++++++++++++------ .../Services/ICacheMatchingStatusService.cs | 17 +++--- 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/PARR.DAL/Cache/Services/CacheMatchingStatusService.cs b/PARR.DAL/Cache/Services/CacheMatchingStatusService.cs index 2293edac..f33c6ea3 100644 --- a/PARR.DAL/Cache/Services/CacheMatchingStatusService.cs +++ b/PARR.DAL/Cache/Services/CacheMatchingStatusService.cs @@ -1,4 +1,5 @@ -using PARR.DAL.Cache.Models; +using PARR.Constants; +using PARR.DAL.Cache.Models; using PARR.DAL.Cache.Services.Base; namespace PARR.DAL.Cache.Services @@ -12,34 +13,51 @@ namespace PARR.DAL.Cache.Services this.redisCacheService = redisCacheService; } - public Task DeleteCacheByJobGroupIdAsync(Guid jobGroupId) + public async Task DeleteCacheAsync(Guid id, SyncTaskEntityTypeEnum type) { - throw new NotImplementedException(); + var key = GetKey(id, type); + + await redisCacheService.DeleteCachedDataAsync(key); } - public Task DeleteCacheByJobIdAsync(Guid jobId) + + public async Task GetDataAsync(Guid id, SyncTaskEntityTypeEnum type) { - throw new NotImplementedException(); + var key = GetKey(id, type); + + return await redisCacheService.GetCachedDataAsync(key); } - public Task GetDataByJobGroupIdAsync(Guid jobGroupId) + + public async Task SetCacheAsync(Guid id, SyncTaskEntityTypeEnum type, MatchingStatusDto data, TimeSpan cacheDuration) { - throw new NotImplementedException(); + var key = GetKey(id, type); + + await redisCacheService.SetCachedDataAsync(key, data, cacheDuration); } - public Task GetDataByJobIdAsync(Guid jobId) + + private string GetKey(Guid id, SyncTaskEntityTypeEnum type) { - throw new NotImplementedException(); + 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() }); } - public Task SetCahcheByJobGroupIdAsync(Guid jobGroupId, MatchingStatusDto data) - { - throw new NotImplementedException(); - } - public Task SetCahcheByJobIdAsync(Guid jobId, MatchingStatusDto data) - { - throw new NotImplementedException(); - } } } diff --git a/PARR.DAL/Cache/Services/ICacheMatchingStatusService.cs b/PARR.DAL/Cache/Services/ICacheMatchingStatusService.cs index c0802569..976b766c 100644 --- a/PARR.DAL/Cache/Services/ICacheMatchingStatusService.cs +++ b/PARR.DAL/Cache/Services/ICacheMatchingStatusService.cs @@ -1,19 +1,18 @@ -using PARR.DAL.Cache.Models; +using PARR.Constants; +using PARR.DAL.Cache.Models; namespace PARR.DAL.Cache.Services { + /// + /// Сервис - статус matching`a + /// public interface ICacheMatchingStatusService { - Task GetDataByJobIdAsync(Guid jobId); + Task GetDataAsync(Guid id, SyncTaskEntityTypeEnum type); - Task GetDataByJobGroupIdAsync(Guid jobGroupId); + Task SetCacheAsync(Guid id, SyncTaskEntityTypeEnum type, MatchingStatusDto data, TimeSpan cacheDuration); - Task SetCahcheByJobIdAsync(Guid jobId, MatchingStatusDto data); + Task DeleteCacheAsync(Guid id, SyncTaskEntityTypeEnum type); - Task SetCahcheByJobGroupIdAsync(Guid jobGroupId, MatchingStatusDto data); - - Task DeleteCacheByJobIdAsync(Guid jobId); - - Task DeleteCacheByJobGroupIdAsync(Guid jobGroupId); } }