1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
function kills($goodsId) { $storeKey = "goods_{$goodsId}_store";
$redis = new redis(); $redis->connect('127.0.0.1', 6379);
$count = $redis->lpop($storeKey); if ($count) { $data = ""; $data["order_sn"] = rand(1000, 9999);
$orderModel = new orderModel(); $result = $orderModel->save($data);
if ($result !== false) { return true; } else { $redis->lpush($storeKey, 1); return false; }
Queue::push($job, $data, 'seckill'); } }
|