增加redis缓存
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.2" />
|
||||
<PackageReference Include="MimeKit" Version="4.6.0" />
|
||||
<PackageReference Include="MySql.Data" Version="8.4.0" />
|
||||
<PackageReference Include="NewLife.Redis" Version="5.7.2024.701" />
|
||||
<PackageReference Include="NewLife.XCode" Version="11.13.2024.606" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Senparc.NeuChar" Version="2.4.1" />
|
||||
|
||||
@@ -18,16 +18,19 @@ using Newtonsoft.Json;
|
||||
using COMCMS.Web.Common;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using System.Text.RegularExpressions;
|
||||
using NewLife.Caching;
|
||||
|
||||
namespace COMCMS.Web.Controllers
|
||||
{
|
||||
public class HomeController : HomeBaseController
|
||||
{
|
||||
private IWebHostEnvironment _env;
|
||||
private readonly ICacheProvider _cacheProvider;
|
||||
|
||||
public HomeController(IWebHostEnvironment env)
|
||||
public HomeController(IWebHostEnvironment env,ICacheProvider cacheProvider)
|
||||
{
|
||||
_env = env;
|
||||
_cacheProvider = cacheProvider;
|
||||
}
|
||||
|
||||
#region 首页
|
||||
@@ -455,6 +458,7 @@ namespace COMCMS.Web.Controllers
|
||||
return View();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 测试
|
||||
public IActionResult Test()
|
||||
{
|
||||
@@ -473,7 +477,13 @@ namespace COMCMS.Web.Controllers
|
||||
|
||||
|
||||
string result = $"t1:{t1}; t2:{t2}; t3:{t3}; t4:{t4}; t5:{t5}; t6:{t6}";
|
||||
return Content(result);
|
||||
|
||||
|
||||
_cacheProvider.Cache.Add("test", "test", 60);
|
||||
|
||||
string a = _cacheProvider.Cache.Get<string>("test");
|
||||
|
||||
return Content(result+";cache:"+ a);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using NewLife.Caching;
|
||||
using NewLife.Caching.Services;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Senparc.CO2NET;
|
||||
using Senparc.CO2NET.Cache;
|
||||
@@ -65,6 +67,7 @@ namespace COMCMS.Web
|
||||
options.Cookie.HttpOnly = true;
|
||||
|
||||
});
|
||||
services.AddSingleton<ICacheProvider, RedisCacheProvider>();
|
||||
//部分系统配置
|
||||
services.Configure<SystemSetting>(Configuration.GetSection("SystemSetting"));
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"Default": "Warning"
|
||||
}
|
||||
},
|
||||
"RedisCache": "server=127.0.0.1;password=;db=2",
|
||||
"SystemSetting": {
|
||||
"FileAllowedExtensions": "zip,rar,7z,doc,docx,xls,xlsx,ppt,pptx,csv,pdf,txt,gz,gzip,gif,png,jpg,jpeg,bmp,avi,fla,flv,swf,mp4,mp3,mov,mid,mpg,mpeg,rm,rmvb,wma,wav,wmv",
|
||||
"ImageAllowedExtensions": "gif,png,jpg,jpeg,bmp",
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
CKEDITOR.editorConfig = function( config ) {
|
||||
// Define changes to default configuration here. For example:
|
||||
//config.language = 'zh-cn';
|
||||
// config.uiColor = '#AADC6E';
|
||||
// config.uiColor = '#AADC6E';
|
||||
config.versionCheck = false;
|
||||
config.baseHref = "http://" + location.host;
|
||||
config.filebrowserImageUploadUrl = '/AdminCP/Upload/CKUploadImage?action=uploadimg';
|
||||
config.filebrowserUploadUrl = '/AdminCP/Upload/CKUploadFile?action=uploadfile';
|
||||
|
||||
Reference in New Issue
Block a user