| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- 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<ActionResult> 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<TkDataDTO>(cacheKey);
- var data2 = await RedisKit.GetAsync<TkDataDTO>(cacheKey);
- await RedisKit.SetAsync(cacheKey, result, 300);
- data1 = RedisHelper.Get<TkDataDTO>(cacheKey);
- data2 = await RedisKit.GetAsync<TkDataDTO>(cacheKey);
- await RedisKit.SetAsync(cacheKey, "a", 300);
- var data3 = RedisHelper.Get<int>(cacheKey);
- var data4 = await RedisKit.GetAsync<int>(cacheKey);
- return new APIResult(new { data = new List<TkDataDTO> { data1, data2 } });
- }
- [HttpGet]
- public async Task<ActionResult> 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,
- });
- }
- }
- }
|