提交代码

This commit is contained in:
zpc 2024-12-09 17:10:36 +08:00
parent c6ab491746
commit d16a678b8b
3 changed files with 455 additions and 466 deletions

View File

@ -5,16 +5,13 @@ using CloudGaming.DtoModel;
using HuanMeng.DotNetCore.AttributeExtend;
using Microsoft.AspNetCore.Mvc;
namespace CloudGaming.Api.Controllers;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace CloudGaming.Api.Controllers
/// <summary>
///
/// </summary>
public class AppController : CloudGamingControllerBase
{
/// <summary>
///
/// </summary>
public class AppController : CloudGamingControllerBase
{
public AppController(IServiceProvider _serviceProvider) : base(_serviceProvider)
{
}
@ -31,5 +28,4 @@ namespace CloudGaming.Api.Controllers
}
}
}

View File

@ -12,13 +12,13 @@ using HuanMeng.DotNetCore.CacheHelper;
using System.Collections.Concurrent;
using System.Linq.Expressions;
namespace CloudGaming.Code.Cache
namespace CloudGaming.Code.Cache;
/// <summary>
/// 缓存数据表
/// </summary>
public class CloudGamingCache
{
/// <summary>
/// 缓存数据表
/// </summary>
public class CloudGamingCache
{
private readonly CloudGamingBase _gamingBase;
public CloudGamingCache(CloudGamingBase gamingBase)
@ -234,21 +234,18 @@ namespace CloudGaming.Code.Cache
}
#endregion
#region
#endregion
}
}
/// <summary>
/// 游戏缓存扩展
/// </summary>
public static class CloudGamingCacheExtend
{
/// <summary>
/// 游戏缓存扩展
/// </summary>
public static class CloudGamingCacheExtend
{
private static readonly ConcurrentDictionary<Type, object> ExtCacheLockList = new ConcurrentDictionary<Type, object>();
private static readonly ConcurrentDictionary<Type, object> GameCacheLockList = new ConcurrentDictionary<Type, object>();
private static readonly ConcurrentDictionary<Type, object> AppCacheLockList = new ConcurrentDictionary<Type, object>();
@ -323,7 +320,6 @@ namespace CloudGaming.Code.Cache
private static void Log(string message)
{
// 替换为其他日志记录系统,例如 NLog, Serilog 等
Console.WriteLine(message);
}
//Console.WriteLine(message);
}
}

View File

@ -1,41 +1,39 @@
using AutoMapper;
using CloudGaming.Code.AppExtend;
using CloudGaming.Code.DataAccess;
using CloudGaming.DtoModel.Game;
using HuanMeng.DotNetCore.CacheHelper;
using HuanMeng.DotNetCore.CacheHelper.Contract;
using HuanMeng.DotNetCore.Redis;
using Newtonsoft.Json;
using StackExchange.Redis;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Net.Mime.MediaTypeNames;
namespace CloudGaming.Code.Cache.Special;
namespace CloudGaming.Code.Cache.Special
/// <summary>
/// 图片缓存表
/// </summary>
/// <param name="dao"></param>
/// <param name="appConfig"></param>
/// <param name="database"></param>
/// <param name="mapper"></param>
/// <param name="appRequestConfig"></param>
public class ImageEntityCache(DAO dao, AppConfig appConfig, IDatabase database, AppRequestConfig appRequestConfig) : ICacheClearData, ICacheReloadData
{
/// <summary>
/// 图片缓存表
/// 是否加载过图片
/// </summary>
/// <param name="dao"></param>
/// <param name="appConfig"></param>
/// <param name="database"></param>
/// <param name="mapper"></param>
/// <param name="appRequestConfig"></param>
public class ImageEntityCache(DAO dao, AppConfig appConfig, IDatabase database, AppRequestConfig appRequestConfig) : ICacheClearData, ICacheReloadData
{
public static bool IsLoadImage { get; set; } = false;
/// <summary>
/// 本地内存图片缓存key
/// </summary>
private string key = $"{appConfig.Identifier}:App:Image";
/// <summary>
/// redis图片缓存key
/// </summary>
private string redisKey = $"App:Image";
/// <summary>
/// 当前使用的图片key
/// </summary>
ConcurrentDictionary<string, ConcurrentDictionary<int, string>>? ImageData { get; set; }
/// <summary>
@ -64,13 +62,10 @@ namespace CloudGaming.Code.Cache.Special
if (!ImageData.TryGetValue(language, out images))
{
ImageData.TryAdd(language, images = new ConcurrentDictionary<int, string>());
//内存中缓存
MemoryCacheHelper.SetCache(key, ImageData, 60 * 60 * 24);
}
return images;
}
}
@ -117,17 +112,6 @@ namespace CloudGaming.Code.Cache.Special
}
imageUrl = imageValue;
_imageData.TryAdd(imageId, imageUrl);
//if (!_imageData.TryGetValue(imageId, out imageUrl))
//{
// if (string.IsNullOrEmpty(imageUrl))
// {
// imageUrl = "";
// }
//}//imageValue.ToString();
//MemoryCacheHelper.SetCache(key, ImageData, 60 * 60 * 24);
}
return imageUrl;
}
@ -191,6 +175,11 @@ namespace CloudGaming.Code.Cache.Special
return _data;
}
/// <summary>
/// 读取图片
/// </summary>
/// <param name="imageId"></param>
/// <returns></returns>
public string this[int imageId]
{
get
@ -200,14 +189,22 @@ namespace CloudGaming.Code.Cache.Special
}
}
/// <summary>
/// 清除缓存
/// </summary>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public bool ClearData()
{
throw new NotImplementedException();
}
/// <summary>
/// 重新加载缓存
/// </summary>
/// <exception cref="NotImplementedException"></exception>
public void ReloadData()
{
throw new NotImplementedException();
}
}
}