using molilian.core; using dodohold.core; using Microsoft.AspNetCore.Mvc; using Org.BouncyCastle.Ocsp; using System.Text.Json; using System.Runtime.InteropServices; using System.Net; using System.Threading; using Microsoft.AspNetCore.Mvc.RazorPages; using TencentCloud.Soe.V20180724.Models; using static dodohold.core.ZTOExpress.CreateOrderArgs; using static Spire.Xls.Core.Spreadsheet.HTMLOptions; using System.Net.Http.Json; using System.Text.RegularExpressions; using System.Text; using TencentCloud.Oceanus.V20190422.Models; using System.Security.Cryptography; using YunhuiKit; using System.Diagnostics; namespace molilian.api.Controllers { [ApiController] [Route("[controller]/[action]")] public class NewController : ControllerBase { protected IHttpContextAccessor _accessor; public NewController(IHttpContextAccessor accessor) { _accessor = accessor; } [HttpGet] public async Task redis() { var result = AlimamaPlus.GetFormattedObject("中国1@#阿斯蒂芬", "127.0.0.1", "0000-00-0000"); string cacheKey = "tmp:test:case1"; RedisHelper.Set(cacheKey, result, 300); var data1 = RedisHelper.Get(cacheKey); var data2 = await RedisKit.GetAsync(cacheKey); await RedisKit.SetAsync(cacheKey, result, 300); data1 = RedisHelper.Get(cacheKey); data2 = await RedisKit.GetAsync(cacheKey); await RedisKit.SetAsync(cacheKey, "a", 300); var data3 = RedisHelper.Get(cacheKey); var data4 = await RedisKit.GetAsync(cacheKey); return new APIResult(new { data = new List { data1, data2 } }); } [HttpGet] public async Task redis2(int count = 100) { var stopwatch = new Stopwatch(); stopwatch.Start(); // 执行100次 for (int i = 0; i < 100; i++) { int total_count = TkLogCore.GetTotal($":total:tb:2025-01-09"); } stopwatch.Stop(); var stopwatch2 = new Stopwatch(); stopwatch2.Start(); // 执行100次 for (int i = 0; i < 100; i++) { int total_count = await TkLogCore.GetTotalAsync($":total:tb:2025-01-09"); } stopwatch2.Stop(); return new APIResult(new { ts = stopwatch.ElapsedMilliseconds, ts2 = stopwatch2.ElapsedMilliseconds, }); } } }