<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Log;
use Mockery\Exception;
use \Redis;
use App\Jobs\SeckillGoods;
class SeckillController extends Controller
{
protected $uid; // 用户id
protected $goodsId = 10086; // 秒抢商品
protected $goodsNum = 100; // 数量限制
protected $redis; // redis实例
protected $lockPrefix = 'lock:';
protected $lockExpireTime = 10;
protected $goodsCacheKeyTag = [
'goodsNumCacheKey' => 'goods_num',
'isSetGoods' => 'is_set_goods_status',
'hadGetGoodsMembers' => 'had_get_goods_members',
'limitUserNumKey' => 'limit_user_num'
];
public function __construct()
{
$redis = new Redis;
$redis->connect('127.0.0.1');
$redis->select(5);
$this->redis = $redis;
$this->uid &
laravel+redis实现的抢购(待优化)
最新推荐文章于 2023-04-07 16:58:19 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)