From 1698d7a4a64200a5273807e181823ed8383ce83e Mon Sep 17 00:00:00 2001 From: Allen Date: Tue, 22 Jul 2025 08:35:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DMemoryCacheService=E4=BD=BF?= =?UTF-8?q?=E7=94=A8Add=E6=96=B9=E6=B3=95=E6=B7=BB=E5=8A=A0=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E9=BB=98=E8=AE=A4=E6=98=AF=E6=BB=91=E5=8A=A8=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CacheManager/Service/MemoryCacheService .cs | 13 ++++++++++++- .../CacheManager/Service/MemoryCacheService .cs | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/vol.api.sqlsugar/VOL.Core/CacheManager/Service/MemoryCacheService .cs b/vol.api.sqlsugar/VOL.Core/CacheManager/Service/MemoryCacheService .cs index b3a67326..a93c7cb3 100644 --- a/vol.api.sqlsugar/VOL.Core/CacheManager/Service/MemoryCacheService .cs +++ b/vol.api.sqlsugar/VOL.Core/CacheManager/Service/MemoryCacheService .cs @@ -52,11 +52,22 @@ namespace VOL.Core.CacheManager { if (expireSeconds != -1) { - _cache.Set(key, + if (isSliding) + { + _cache.Set(key, value, new MemoryCacheEntryOptions() .SetSlidingExpiration(new TimeSpan(0, 0, expireSeconds)) ); + } + else + { + _cache.Set(key, + value, + new MemoryCacheEntryOptions() + .SetAbsoluteExpiration(new TimeSpan(0, 0, expireSeconds)) + ); + } } else { diff --git a/vol.api/VOL.Core/CacheManager/Service/MemoryCacheService .cs b/vol.api/VOL.Core/CacheManager/Service/MemoryCacheService .cs index b3a67326..a93c7cb3 100644 --- a/vol.api/VOL.Core/CacheManager/Service/MemoryCacheService .cs +++ b/vol.api/VOL.Core/CacheManager/Service/MemoryCacheService .cs @@ -52,11 +52,22 @@ namespace VOL.Core.CacheManager { if (expireSeconds != -1) { - _cache.Set(key, + if (isSliding) + { + _cache.Set(key, value, new MemoryCacheEntryOptions() .SetSlidingExpiration(new TimeSpan(0, 0, expireSeconds)) ); + } + else + { + _cache.Set(key, + value, + new MemoryCacheEntryOptions() + .SetAbsoluteExpiration(new TimeSpan(0, 0, expireSeconds)) + ); + } } else { -- Gitee