This commit is contained in:
Putoo
2026-07-14 17:51:41 +08:00
parent 578d6f23db
commit 171388d7e8
2 changed files with 7 additions and 5 deletions

View File

@@ -209,7 +209,7 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
private async Task<long> GetUserDrugLockTime(string userId, int goodsId)
{
long result = 0;
string key = string.Format(UserCache.BaseCacheKey, "UserDrug", $"Lock:{userId}_{goodsId}");
string key = string.Format(UserCache.BaseCacheKeys, "UserDrug", $"Lock:{userId}_{goodsId}");
if (await redis.ExistsAsync(key))
{
long end = await redis.GetAsync<long>(key);
@@ -225,7 +225,7 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
if (time > 0)
{
long end = TimeExtend.GetTimeStampSeconds + time;
string key = string.Format(UserCache.BaseCacheKey, "UserDrug", $"Lock:{userId}_{goodsId}");
string key = string.Format(UserCache.BaseCacheKeys, "UserDrug", $"Lock:{userId}_{goodsId}");
await redis.SetAsync(key, end, time);
}
}
@@ -235,7 +235,8 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
int result = 0;
if (!string.IsNullOrEmpty(scene))
{
string key = string.Format(UserCache.BaseCacheKey, "UserDrug", $"Count:{scene}:{userId}_{goodsId}");
string maiId = $"Count:{scene}:{userId}_{goodsId}";
string key = string.Format(UserCache.BaseCacheKeys, "UserDrug", maiId);
if (await redis.ExistsAsync(key))
{
result = await redis.GetAsync<int>(key);
@@ -251,7 +252,8 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
{
var count = await GetUserDrugLockCount(userId, goodsId, scene);
count += 1;
string key = string.Format(UserCache.BaseCacheKey, "UserDrug", $"Count:{scene}:{userId}_{goodsId}");
string maiId = $"Count:{scene}:{userId}_{goodsId}";
string key = string.Format(UserCache.BaseCacheKeys, "UserDrug",maiId);
await redis.SetAsync(key, count, 43200);
}
}