getRootPath(); $appAppPath = app()->getAppPath(); $memoryLimit = ini_get('memory_limit'); $uploadMax = ini_get('upload_max_filesize'); $postMax = ini_get('post_max_size'); $max_execution_time = ini_get('max_execution_time'); //最大执行时间(秒) $max_input_time = ini_get('max_input_time'); // 输入解析时间限制 return json(['code' => '0', 'msg' => 'SUCCESS', 'data' => [ 'memory_limit' => $memoryLimit, 'upload_max' => $uploadMax, 'post_max' => $postMax, 'max_execution_time' => $max_execution_time, 'max_input_time' => $max_input_time, 'app_root_path' => $appRootPath, 'app_path' => $appAppPath, 'app_number' => $appNumber ]]); } public function testMongo() { $client = MongoConnection::getClient(); $collection = $client->selectCollection('bourse', 'stockListBak'); // 分页计算 $page = 1; $pageSize = 10; $options = [ 'skip' => ($page - 1) * $pageSize, 'limit' => $pageSize, 'sort' => ['_id' => -1], // 按创建时间倒序 ]; // 构造查询条件 $filter = []; $filterName = 'xxx'; if (!empty($filterName)) { // 使用正则表达式进行模糊匹配(i 表示不区分大小写) $filter['Name'] = [ '$regex' => 'POP', '$options' => 'i' // i = ignore case ]; } // 查询数据 $cursor = $collection->find($filter, $options); $total = $collection->countDocuments($filter); // 将 BSON 文档转换为数组 $results = iterator_to_array($cursor); $data = []; foreach ($results as $item) { $arr = (array)$item; $data[] = $arr; if ($arr['Name'] == "POPULAR FOUNDATIONS LIMITED") { $oidArr = (array)$arr['_id']; echo "oid===".$oidArr['oid']; // 将目标缓存到redis队列中 $res = Cache::store('redis')->lPush('STOCK_MARKET_TOP_DATA', $oidArr['oid']); echo "cache res=="; var_dump($res); echo PHP_EOL; } } return json( [ 'total' => $total, 'page' => $page, 'pageSize' => $pageSize, 'data' => $data ]); } }