文件名称:[asp.net core 1.1 供参考]SeckillPro.zip
文件大小:16.12MB
文件格式:ZIP
更新时间:2023-06-23 09:28:35
mvc webapi asp.net core
描述:秒杀活动,模拟,架构:mvc+webapi+console+redis,netcore开发
static void Main(string[] args)
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Console.OutputEncoding = Encoding.GetEncoding("GB2312");
try
{
Console.WriteLine("是否开启处理抢购队列(Y):");
Console.ReadLine();
Console.WriteLine($"开启抢购任务监控中...");
var shopsKey = EnumHelper.EmDataKey.ShoppingHash.ToString();
while (true)
{
//匹配出QiangOrderEqueue_xxx格式的抢单队列keys
var matchKey = $"{EnumHelper.EmDataKey.QiangOrderEqueue.ToString()}_*";
var matches = _redis.MatchKeys(matchKey).Result;
var matchLen = matches.Count;
if (matchLen <= 0) { continue; }
//根据key获取对应的商品,并加载对应的商品抢单任务处理
foreach (var item in matches)
{
var itemArr = item.Split('_');
if (itemArr.Length <= 1) { continue; }
var shopId = itemArr[1];
var shop = _redis.GetHashField