提交代码
This commit is contained in:
parent
c6ab491746
commit
d16a678b8b
|
|
@ -5,16 +5,13 @@ using CloudGaming.DtoModel;
|
||||||
using HuanMeng.DotNetCore.AttributeExtend;
|
using HuanMeng.DotNetCore.AttributeExtend;
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
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
|
/// <summary>
|
||||||
|
///
|
||||||
namespace CloudGaming.Api.Controllers
|
/// </summary>
|
||||||
|
public class AppController : CloudGamingControllerBase
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
public class AppController : CloudGamingControllerBase
|
|
||||||
{
|
|
||||||
public AppController(IServiceProvider _serviceProvider) : base(_serviceProvider)
|
public AppController(IServiceProvider _serviceProvider) : base(_serviceProvider)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -31,5 +28,4 @@ namespace CloudGaming.Api.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,13 @@ using HuanMeng.DotNetCore.CacheHelper;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Linq.Expressions;
|
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;
|
private readonly CloudGamingBase _gamingBase;
|
||||||
|
|
||||||
public CloudGamingCache(CloudGamingBase gamingBase)
|
public CloudGamingCache(CloudGamingBase gamingBase)
|
||||||
|
|
@ -234,21 +234,18 @@ namespace CloudGaming.Code.Cache
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region 首页缓存表
|
#region 首页缓存表
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 游戏缓存扩展
|
/// 游戏缓存扩展
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class CloudGamingCacheExtend
|
public static class CloudGamingCacheExtend
|
||||||
{
|
{
|
||||||
private static readonly ConcurrentDictionary<Type, object> ExtCacheLockList = new ConcurrentDictionary<Type, object>();
|
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> GameCacheLockList = new ConcurrentDictionary<Type, object>();
|
||||||
private static readonly ConcurrentDictionary<Type, object> AppCacheLockList = 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)
|
private static void Log(string message)
|
||||||
{
|
{
|
||||||
// 替换为其他日志记录系统,例如 NLog, Serilog 等
|
// 替换为其他日志记录系统,例如 NLog, Serilog 等
|
||||||
Console.WriteLine(message);
|
//Console.WriteLine(message);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,39 @@
|
||||||
using AutoMapper;
|
|
||||||
|
|
||||||
using CloudGaming.Code.AppExtend;
|
|
||||||
using CloudGaming.Code.DataAccess;
|
using CloudGaming.Code.DataAccess;
|
||||||
using CloudGaming.DtoModel.Game;
|
|
||||||
|
|
||||||
using HuanMeng.DotNetCore.CacheHelper;
|
using HuanMeng.DotNetCore.CacheHelper;
|
||||||
using HuanMeng.DotNetCore.CacheHelper.Contract;
|
using HuanMeng.DotNetCore.CacheHelper.Contract;
|
||||||
using HuanMeng.DotNetCore.Redis;
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
using StackExchange.Redis;
|
using StackExchange.Redis;
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Concurrent;
|
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>
|
||||||
/// 图片缓存表
|
/// 是否加载过图片
|
||||||
/// </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;
|
public static bool IsLoadImage { get; set; } = false;
|
||||||
|
/// <summary>
|
||||||
|
/// 本地内存图片缓存key
|
||||||
|
/// </summary>
|
||||||
private string key = $"{appConfig.Identifier}:App:Image";
|
private string key = $"{appConfig.Identifier}:App:Image";
|
||||||
|
/// <summary>
|
||||||
|
/// redis图片缓存key
|
||||||
|
/// </summary>
|
||||||
private string redisKey = $"App:Image";
|
private string redisKey = $"App:Image";
|
||||||
|
/// <summary>
|
||||||
|
/// 当前使用的图片key
|
||||||
|
/// </summary>
|
||||||
ConcurrentDictionary<string, ConcurrentDictionary<int, string>>? ImageData { get; set; }
|
ConcurrentDictionary<string, ConcurrentDictionary<int, string>>? ImageData { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -64,13 +62,10 @@ namespace CloudGaming.Code.Cache.Special
|
||||||
if (!ImageData.TryGetValue(language, out images))
|
if (!ImageData.TryGetValue(language, out images))
|
||||||
{
|
{
|
||||||
ImageData.TryAdd(language, images = new ConcurrentDictionary<int, string>());
|
ImageData.TryAdd(language, images = new ConcurrentDictionary<int, string>());
|
||||||
|
//内存中缓存
|
||||||
MemoryCacheHelper.SetCache(key, ImageData, 60 * 60 * 24);
|
MemoryCacheHelper.SetCache(key, ImageData, 60 * 60 * 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
return images;
|
return images;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -117,17 +112,6 @@ namespace CloudGaming.Code.Cache.Special
|
||||||
}
|
}
|
||||||
imageUrl = imageValue;
|
imageUrl = imageValue;
|
||||||
_imageData.TryAdd(imageId, imageUrl);
|
_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;
|
return imageUrl;
|
||||||
}
|
}
|
||||||
|
|
@ -191,6 +175,11 @@ namespace CloudGaming.Code.Cache.Special
|
||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取图片
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="imageId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public string this[int imageId]
|
public string this[int imageId]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -200,14 +189,22 @@ namespace CloudGaming.Code.Cache.Special
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清除缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
public bool ClearData()
|
public bool ClearData()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重新加载缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
public void ReloadData()
|
public void ReloadData()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user