缓存测试

This commit is contained in:
陈淳
2022-10-26 20:08:16 +08:00
parent 3a634d7888
commit dfe877c438
4 changed files with 35 additions and 2 deletions

View File

@@ -529,7 +529,7 @@
测试控制器
</summary>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.#ctor(Microsoft.AspNetCore.SignalR.IHubContext{Yi.Framework.WebCore.SignalRHub.MainHub},Microsoft.Extensions.Logging.ILogger{Yi.Framework.Model.Models.UserEntity},Yi.Framework.Interface.IRoleService,Yi.Framework.Interface.IUserService,Microsoft.Extensions.Localization.IStringLocalizer{Yi.Framework.Language.LocalLanguage},Yi.Framework.Core.QuartzInvoker,Yi.Framework.Core.ThumbnailSharpInvoer)">
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.#ctor(Microsoft.AspNetCore.SignalR.IHubContext{Yi.Framework.WebCore.SignalRHub.MainHub},Microsoft.Extensions.Logging.ILogger{Yi.Framework.Model.Models.UserEntity},Yi.Framework.Interface.IRoleService,Yi.Framework.Interface.IUserService,Microsoft.Extensions.Localization.IStringLocalizer{Yi.Framework.Language.LocalLanguage},Yi.Framework.Core.QuartzInvoker,Yi.Framework.Core.ThumbnailSharpInvoer,Yi.Framework.Core.CacheInvoker)">
<summary>
依赖注入
</summary>
@@ -540,6 +540,7 @@
<param name="local"></param>
<param name="quartzInvoker"></param>
<param name="thumbnailSharpInvoer"></param>
<param name="cacheInvoker"></param>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.Swagger">
<summary>
@@ -645,5 +646,11 @@
</summary>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.CacheDBTest">
<summary>
缓存测试
</summary>
<returns></returns>
</member>
</members>
</doc>

View File

@@ -36,6 +36,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
private QuartzInvoker _quartzInvoker;
private IHubContext<MainHub> _hub;
private ThumbnailSharpInvoer _thumbnailSharpInvoer;
private CacheInvoker _cacheDb;
//你可以依赖注入服务层各各接口,也可以注入其他仓储层,怎么爽怎么来!
/// <summary>
/// 依赖注入
@@ -47,7 +48,15 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// <param name="local"></param>
/// <param name="quartzInvoker"></param>
/// <param name="thumbnailSharpInvoer"></param>
public TestController(IHubContext<MainHub> hub, ILogger<UserEntity> logger, IRoleService iRoleService, IUserService iUserService, IStringLocalizer<LocalLanguage> local, QuartzInvoker quartzInvoker, ThumbnailSharpInvoer thumbnailSharpInvoer)
/// <param name="cacheInvoker"></param>
public TestController(IHubContext<MainHub> hub,
ILogger<UserEntity> logger,
IRoleService iRoleService,
IUserService iUserService,
IStringLocalizer<LocalLanguage> local,
QuartzInvoker quartzInvoker,
ThumbnailSharpInvoer thumbnailSharpInvoer,
CacheInvoker cacheInvoker)
{
_iUserService = iUserService;
_iRoleService = iRoleService;
@@ -55,6 +64,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
_hub = hub;
_local = local;
_thumbnailSharpInvoer = thumbnailSharpInvoer;
_cacheDb = cacheInvoker;
}
/// <summary>
@@ -321,5 +331,20 @@ namespace Yi.Framework.ApiMicroservice.Controllers
}
return Result.Success();
}
/// <summary>
/// 缓存测试
/// </summary>
/// <returns></returns>
[HttpGet]
public Result CacheDBTest()
{
var key = "Yi:Test";
var item = "你好世界";
_cacheDb.Set(key, item);
var data = _cacheDb.Get<string>(key);
return Result.Success().SetData(data);
}
}
}

View File

@@ -10,6 +10,7 @@
<PackageReference Include="CSRedisCore" Version="3.6.9" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />