<?php $redis = new Redis(); $redis->connect('127.0.0.1', 6379); $UserID = (int) $_GET['UserID']; $ActivityID = (int) $_GET['ActivityID']; // 库存检查 if ($redis->decr('Amount') < 0) { $redis->incr('Amount'); echo '{ "exception" : "InvalidNumberException" }'; exit; } // 直接入库 $NoRepeat = $redis->hSet('UserList', $UserID, sprintf('{ "ActivityID" : %d, "Milliseconds" : "%.0f" }', $ActivityID, round(microtime(true) * 1000)) ); if (!$NoRepeat) { // 还原库存 $redis->incr('Amount'); echo '{ "exception" : "SaveInvalidException" }'; exit; } echo sprintf('{ "errno" : 0 , "data" : { "UserID" : %d, "Milliseconds": %.0f } }', $UserID, round(microtime(true) * 1000)); exit;
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号