This commit is contained in:
tongfei
2024-04-18 14:33:25 +08:00
parent a79893ffb5
commit a23321e1d2
6 changed files with 53 additions and 14 deletions

View File

@@ -17,13 +17,21 @@ namespace WMS.Web.Domain.Services.Public
public bool CanAccessMethod(string cacheKey)
{
// 使用 Redis 来存储并发控制标记
return _redisClientService.SetStringKey(cacheKey, "true", TimeSpan.FromMinutes(1));
return _redisClientService.SetStringKey<bool>(cacheKey, true, TimeSpan.FromMinutes(1));
}
public bool GetRedisKeyValue(string cacheKey)
{
// 使用 Redis 来存储并发控制标记
var isSuccess= _redisClientService.GetStringKey<bool>(cacheKey);
return isSuccess;
}
public void UpdateAccessStatus(string cacheKey, bool canAccess)
{
// 更新 Redis 缓存项的值
_redisClientService.SetStringKey(cacheKey, canAccess.ToString(), TimeSpan.FromMinutes(1));
_redisClientService.SetStringKey<bool>(cacheKey, canAccess, TimeSpan.FromMinutes(1));
}
}
}