热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

php操作MongoDB类实例_PHP教程

php操作MongoDB类实例。php操作MongoDB类实例本文实例讲述了php操作MongoDB类的方法。分享给大家供大家参考。具体如下:1.MyMongo.php文件:?123456789101112

php操作MongoDB类实例


本文实例讲述了php操作MongoDB类的方法。分享给大家供大家参考。具体如下:

1. MyMongo.php文件:

?

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

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

/**

* 仿写CI的MongoDB

* @author sparkHuang 2011-11-03

*

*/

class MyMongo {

private $mongo_cOnfig= "mongo_config.php";

private $connection;

private $db;

private $mongo_connect_string;

private $host;

private $port;

private $user;

private $pass;

private $dbname;

private $persist;

private $persist_key;

private $selects = array();

private $wheres = array();

private $sorts = array();

private $limit = 999999;

private $offset = 0;

public function __construct() {

if ( ! class_exists('Mongo')) {

$this->log_error("The MongoDB PECL extentiosn has not been installed or enabled.");

exit;

}

$this->connection_string();

$this->connect();

}

/**

* 更改数据库

*

*/

public function switch_db($database = '') {

if (empty($database)) {

$this->log_error("To switch MongoDB databases, a new database name must be specified");

exit;

}

$this->dbname = $database;

try {

$this->db = $this->connection->{$this->dbname};

return true;

} catch(Exception $e) {

$this->log_error("Unable to switch Mongo Databases: {$e->getMessage()}");

exit;

}

}

/**

* 设置select字段

*

*/

public function select($includs = array(), $excludes = array()) {

if ( ! is_array($includs)) {

$includs = (array)$includs;

}

if ( ! is_array($excludes)) {

$excludes = (array)$excludes;

}

if ( ! empty($includs)) {

foreach ($includs as $col) {

$this->selects[$col] = 1;

}

} else {

foreach ($excludes as $col) {

$this->selects[$col] = 0;

}

}

return($this);

}

/**

* where条件查询判断

*

* @usage = $this->mongo_db->where(array('foo' => 'bar'))->get('foobar');

*

*/

public function where($wheres = array()) {

if ( ! is_array($wheres)) {

$wheres = (array)$wheres;

}

if ( ! empty($wheres)) {

foreach($wheres as $wh => $val) {

$this->wheres[$wh] = $val;

}

}

return($this);

}

/**

* where ... in .. 条件查询判断

*

* @usage = $this->mongo_db->where_in('foo', array('bar', 'zoo'))->get('foobar');

*

*/

public function where_in($field = '', $in = array()) {

$this->where_init($field);

$this->wheres[$field]['$in'] = $in;

return($this);

}

/**

* where ... not in .. 条件查询判断

*

* @usage = $this->mongo_db->where_not_in('foo', array('bar', 'zoo'))->get('foobar');

*

*/

public function where_not_in($field = '', $in = array()) {

$this->where_init($field);

$this->wheres[$field]['$nin'] = $in;

return($this);

}

/**

* where ... $field > $x .. 条件查询判断

*

* @usage = $this->mongo_db->where_gt('foo', 20)->get('foobar');

*

*/

public function where_gt($field = '', $x) {

$this->where_init($field);

$this->wheres[$field]['$gt'] = $x;

return($this);

}

/**

* where ... $field >= $x .. 条件查询判断

*

* @usage = $this->mongo_db->where_gte('foo', 20)->get('foobar');

*

*/

public function where_gte($field = '', $x) {

$this->where_init($field);

$this->wheres[$field]['$gte'] = $x;

return($this);

}

/**

* where ... $field <$x .. 条件查询判断

*

* @usage = $this->mongo_db->where_lt('foo', 20)->get('foobar');

*

*/

public function where_lt($field = '', $x) {

$this->where_init($field);

$this->wheres[$field]['$lt'] = $x;

return($this);

}

/**

* where ... $field <= $x .. 条件查询判断

*

* @usage = $this->mongo_db->where_lte('foo', 20)->get('foobar');

*

*/

public function where_lte($field = '', $x) {

$this->where_init($field);

$this->wheres[$field]['$lte'] = $x;

return($this);

}

/**

* where ... $field >= $x AND $field <= $y .. 条件查询判断

*

* @usage = $this->mongo_db->where_between('foo', 20, 30)->get('foobar');

*

*/

public function where_between($field = '', $x, $y) {

$this->where_init($field);

$this->wheres[$field]['$gte'] = $x;

$this->wheres[$field]['$lte'] = $y;

return($this);

}

/**

* where ... $field > $x AND $field <$y .. 条件查询判断

*

* @usage = $this->mongo_db->where_between_ne('foo', 20, 30)->get('foobar');

*

*/

public function where_between_ne($field = '', $x, $y) {

$this->where_init($field);

$this->wheres[$field]['$gt'] = $x;

$this->wheres[$field]['$lt'] = $y;

return($this);

}

/**

* where ... $field <> $x .. 条件查询判断

*

* @usage = $this->mongo_db->where_ne('foo', 20)->get('foobar');

*

*/

public function where_ne($field = '', $x) {

$this->where_init($field);

$this->wheres[$field]['$ne'] = $x;

return($this);

}

/**

* where ... or .. 条件查询判断

*

* @usage = $this->mongo_db->where_or('foo', array('foo', 'bar'))->get('foobar');

*

*/

public function where_or($field = '', $values) {

$this->where_init($field);

$this->wheres[$field]['$or'] = $values;

return($this);

}

/**

* where ... and .. 条件查询判断

*

* @usage = $this->mongo_db->where_and( array ( 'foo' => 1, 'b' => 'someexample' );

*/

public function where_and( $elements_values = array() ) {

foreach ( $elements_values as $element => $val ) {

$this->wheres[$element] = $val;

}

return($this);

}

/**

* where $field % $num = $result

*

* @usage = $this->mongo_db->where_mod( 'foo', 10, 1 );

*/

public function where_mod( $field, $num, $result ) {

$this->where_init($field);

$this->wheres[$field]['$mod'] = array($num, $result);

return($this);

}

/**

* where size

*

* Get the documents where the size of a field is in a given $size int

*

* @usage : $this->mongo_db->where_size('foo', 1)->get('foobar');

*/

public function where_size($field = "", $size = "") {

$this->where_init($field);

$this->wheres[$field]['$size'] = $size;

return ($this);

}

/**

* like条件查询(PHP中定义MongoRegex类实现)

*

* @usage : $this->mongo_db->like('foo', 'bar', 'im', false, false)->get();

*/

public function like($field = "", $value = "", $flags = "i", $enable_start_wildcard = true, $enable_end_wildcard = true) {

$field = (string)$field;

$this->where_init($field);

$value = (string)$value;

$value = quotmeta($value);

if (true !== $enable_start_wildcard) {

$value = "^".$value;

}

if (true !== $enable_end_wildcard) {

$value .= "$";

}

$regex = "/$value/$flags";

$this->wheres[$field] = new MongoRegex($regex);

return($this);

}

/**

* order排序( 1 => ASC, -1 => DESC)

*

* @usage: $this->mongo_db->get_where('foo', array('name' => 'tom'))->order_by(array("age" => 1));

*/

public function order_by($fields = array()) {

foreach($fields as $col => $val) {

if ($val == -1 || $val == false || strtolower($val) == "desc") {

$this->sorts[$col] = -1;

} else {

$this->sorts[$col] = 1;

}

}

return($this);

}

/**

* limit

*

* @usage: $this->mongo_db->get_where('foo', array('name' => 'tom'))->limit(10);

*/

public function limit($x = 999999) {

if ($x !== NULL && is_numeric($x) && $x >= 1) {

$this->limit = (int)$x;

}

return($this);

}

/**

* offset

*

* @usage: $this->mongo_db->get_where('foo', array('name' => 'tom'))->offset(10);

*/

public function offset($x = 0) {

if($x !== NULL && is_numeric($x) && $x >= 1) {

$this->offset = (int) $x;

}

return($this);

}

/**

* get_where

*

* @usage: $this->mongo_db->get_where('foo', array('bar' => 'something'));

*/

public function get_where($collection = "", $where = array(), $limit = 999999) {

return($this->where($where)->limit($limit)->get($collection));

}

/**

* get

*

* @usage: $this->mongo_db->where(array('name' => 'tom'))->get('foo');

*/

public function get($collection) {

if (empty($collection)) {

$this->log_error("In order to retreive documents from MongoDB, a collection name must be passed");

exit;

}

$results = array();

$results = $this->db->{$collection}->find($this->wheres, $this->selects)->limit((int)$this->limit)->skip((int)$this->offset)->sort($this->sorts);

$returns = array();

foreach($results as $result) {

$returns[] = $result;

}

$this->clear();

return($returns);

}

/**

* count

*

* @usage: $this->db->get_where('foo', array('name' => 'tom'))->count('foo');

*/

public function count($collection) {

if (empty($collection)) {

$this->log_error("In order to retreive documents from MongoDB, a collection name must be passed");

exit;

}

$count = $this->db->{$collection}->find($this->wheres)->limit((int)$this->limit)->skip((int)$this->offset)->count();

$this->clear();

return($count);

}

/**

* insert

*

* @usage: $this->mongo_db->insert('foo', array('name' => 'tom'));

*/

public function insert($collection = "", $data = array()) {

if (empty($collection)) {

$this->log_error("No Mongo collection selected to delete from");

exit;

}

if (count($data) == 0 || ! is_array($data)) {

$this->log_error("Nothing to insert into Mongo collection or insert is not an array");

exit;

}

try {

$this->db->{$collection}->insert($data, array('fsync' => true));

if (isset($data['_id'])) {

return($data['_id']);

} else {

return(false);

}

} catch(MongoCursorException $e) {

$this->log_error("Insert of data into MongoDB failed: {$e->getMessage()}");

exit;

}

}

/**

* update : 利用MongoDB的 $set 实现

*

* @usage : $this->mongo_db->where(array('name' => 'tom'))->update('foo', array('age' => 24))

*/

public function update($collection = "", $data = array()) {

if (empty($collection)) {

$this->log_error("No Mongo collection selected to delete from");

exit;

}

if (count($data) == 0 || ! is_array($data)) {

$this->log_error("Nothing to update in Mongo collection or update is not an array");

exit;

}

try {

$this->db->{$collection}->update($this->wheres, array('$set' => $data), array('fsync' => true, 'multiple' => false)); //注意: multiple为false

return(true);

} catch(MongoCursorException $e) {

$this->log_error("Update of data into MongoDB failed: {$e->getMessage()}");

exit;

}

}

/**

* update_all : 利用MongoDB的 $set 实现

*

* @usage : $this->mongo_db->where(array('name' => 'tom'))->update_all('foo', array('age' => 24));

*/

public function update_all($collection = "", $data = array()) {

if (empty($collection)) {

$this->log_error("No Mongo collection selected to delete from");

exit;

}

if (count($data) == 0 || ! is_array($data)) {

$this->log_error("Nothing to update in Mongo collection or update is not an array");

exit;

}

try {

$this->db->{$collection}->update($this->wheres, array('$set' => $data), array('fsync' => true, 'multiple' => true)); //注意: multiple为true

return(true);

} catch(MongoCursorException $e) {

$this->log_error("Update of data into MongoDB failed: {$e->getMessage()}");

exit;

}

}

/**

* delete

*

* @usage : $this->mongo_db->where(array('name' => 'tom'))->delete('foo');

*/

public function delete($collection = "") {

if (empty($collection)) {

$this->log_error("No Mongo collection selected to delete from");

exit;

}

try {

$this->db->{$collection}->remove($this->wheres, array('fsync' => true, 'justOne' => true)); //注意justOne为true;

} catch(MongoCursorException $e) {

$this->log_error("Delete of data into MongoDB failed: {$e->getMessage()}");

exit;

}

}

/**

* delete_all

*

* @usage : $this->mongo_db->where(array('name' => 'tom'))->delete_all('foo');

*/

public function delete_all($collection = "") {

if (empty($collection)) {

$this->log_error("No Mongo collection selected to delete from");

exit;

}

try {

$this->db->{$collection}->remove($this->wheres, array('fsync' => true, 'justOne' => false)); //注意justOne为false;

} catch(MongoCursorException $e) {

$this->log_error("Delete of data into MongoDB failed: {$e->getMessage()}");

exit;

}

}

/**

* add_index

*

* @usage : $this->mongo_db->add_index('foo', array('first_name' => 'ASC', 'last_name' => -1), array('unique' => true)));

*/

public function add_index($collection, $keys = array(), $optiOns= array()) {

if (empty($collection)) {

$this->log_error("No Mongo collection specified to add index to");

exit;

}

if (empty($keys) || ! is_array($keys)) {

$this->log_error("Index could not be created to MongoDB Collection because no keys were specified");

exit;

}

foreach($keys as $col => $val) {

if ($val == -1 || $val == false || strtolower($val) == 'desc') {

$keys[$col] = -1;

} else {

$keys[$col] = 1;

}

}

//在此没有对$options数组的有效性进行验证

if (true == $this->db->{$collection}->ensureIndex($keys, $options)) {

$this->clear();

return($this);

} else {

$this->log_error("An error occured when trying to add an index to MongoDB Collection");

exit;

}

}

/**

* remove_index

*

* @usage : $this->mongo_db->remove_index('foo', array('first_name' => 'ASC', 'last_name' => -1))

*/

public function remove_index($collection = "", $keys = array()) {

if (empty($collection)) {

$this->log_error("No Mongo collection specified to add index to");

exit;

}

if (empty($keys) || ! is_array($keys)) {

$this->log_error("Index could not be created to MongoDB Collection because no keys were specified");

exit;

}

if ($this->db->{$collection}->deleteIndex($keys)) {

$this->clear();

return($this);

} else {

$this->log_error("An error occured when trying to add an index to MongoDB Collection");

exit;

}

}

/**

* remove_all_index

*

* @usage : $this->mongo_db->remove_all_index('foo', array('first_name' => 'ASC', 'last_name' => -1))

*/

public function remove_all_index($collection = "", $keys = array()) {

if (empty($collection)) {

$this->log_error("No Mongo collection specified to add index to");

exit;

}

if (empty($keys) || ! is_array($keys)) {

$this->log_error("Index could not be created to MongoDB Collection because no keys were specified");

exit;

}

if ($this->db->{$collection}->deleteIndexes($keys)) {

$this->clear();

return($this);

} else {

$this->log_error("An error occured when trying to add an index to MongoDB Collection");

exit;

}

}

/**

* list_indexes

*

* @usage : $this->mongo_db->list_indexes('foo');

*/

public function list_indexes($collection = "") {

if (empty($collection)) {

$this->log_error("No Mongo collection specified to add index to");

exit;

}

return($this->db->{$collection}->getIndexInfo());

}

/**

* drop_collection

*

* @usage : $this->mongo_db->drop_collection('foo');

*/

public function drop_collection($collection = "") {

if (empty($collection)) {

$this->log_error("No Mongo collection specified to add index to");

exit;

}

$this->db->{$collection}->drop();

return(true);

}

/**

* 生成连接MongoDB 参数字符串

*

*/

private function connection_string() {

include_once($this->mongo_config);

$this->host = trim($config['host']);

$this->port = trim($config['port']);

$this->user = trim($config['user']);

$this->pass = trim($config['pass']);

$this->dbname = trim($config['dbname']);

$this->persist = trim($config['persist']);

$this->persist_key = trim($config['persist_key']);

$connection_string = "mongodb://";

if (empty($this->host)) {

$this->log_error("The Host must be set to connect to MongoDB");

exit;

}

if (empty($this->dbname)) {

$this->log_error("The Database must be set to connect to MongoDB");

exit;

}

if ( ! empty($this->user) && ! empty($this->pass)) {

$connection_string .= "{$this->user}:{$this->pass}@";

}

if ( isset($this->port) && ! empty($this->port)) {

$connection_string .= "{$this->host}:{$this->port}";

} else {

$connection_string .= "{$this->host}";

}

$this->connection_string = trim($connection_string);

}

/**

* 连接MongoDB 获取数据库操作句柄

*

*/

private function connect() {

$optiOns= array();

if (true === $this->persist) {

$options['persist'] = isset($this->persist_key) && ! empty($this->persist_key) ? $this->persist_key : "ci_mongo_persist";

}

try {

$this->cOnnection= new Mongo($this->connection_string, $options);

$this->db = $this->connection->{$this->dbname};

return ($this);

} catch (MongoConnectionException $e) {

$this->log_error("Unable to connect to MongoDB: {$e->getMessage()}");

}

}

/**

* 初始化清理部分成员变量

*

*/

private function clear() {

$this->selects = array();

$this->wheres = array();

$this->limit = NULL;

$this->offset = NULL;

$this->sorts = array();

}

/**

* 依据字段名初始化处理$wheres数组

*

*/

private function where_init($param) {

if ( ! isset($this->wheres[$param])) {

$this->wheres[$param] = array();

}

}

/**

* 错误记录

*

*/

private function log_error($msg) {

$msg = "[Date: ".date("Y-m-i H:i:s")."] ".$msg;

@file_put_contents("./error.log", print_r($msg."\n", true), FILE_APPEND);

}

}

/* End of MyMongo.php */

2. mongo_config.php配置文件:

?

1

2

3

4

5

6

7

8

9

$config["host"] = "localhost";

$config["user"] = "";

$config["pass"] = "";

$config["port"] = 27017;

$config["dbname"] = "test";

$config['persist'] = TRUE;

$config['persist_key'] = 'ci_mongo_persist';

/*End of mongo_config.php*/

3. MyMongoDemo.php文件:

?

1

2

3

4

5

6

7

8

9

10

11

&#65279;

include_once("MyMongo.php");

$cOnn= new MyMongo();

//删除所有记录

$conn->delete_all("blog");

//插入第一条记录

$value = array("name" => "小明", "age" => 25, "addr" => array("country" => "中国", "province" => "广西", "city" => "桂林"));

$conn->insert("blog", $value);

var_dump($conn->select(array("name", "age"))->get("blog"));

var_dump($conn->get("blog"));

/* End of MyMongoDemo.php */

希望本文所述对大家的php程序设计有所帮助。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1017840.htmlTechArticlephp操作MongoDB类实例 本文实例讲述了php操作MongoDB类的方法。分享给大家供大家参考。具体如下: 1. MyMongo.php文件: ? 1 2 3 4 5 6 7 8 9 10 11 12...


推荐阅读
  • 本文探讨了2019年前端技术的发展趋势,包括工具化、配置化和泛前端化等方面,并提供了详细的学习路线和职业规划建议。 ... [详细]
  • 在Ubuntu 16.04中使用Anaconda安装TensorFlow
    本文详细介绍了如何在Ubuntu 16.04系统上通过Anaconda环境管理工具安装TensorFlow。首先,需要下载并安装Anaconda,然后配置环境变量以确保系统能够识别Anaconda命令。接着,创建一个特定的Python环境用于安装TensorFlow,并通过指定的镜像源加速安装过程。最后,通过一个简单的线性回归示例验证TensorFlow的安装是否成功。 ... [详细]
  • 在现代Web应用中,当用户滚动到页面底部时,自动加载更多内容的功能变得越来越普遍。这种无刷新加载技术不仅提升了用户体验,还优化了页面性能。本文将探讨如何实现这一功能,并介绍一些实际应用案例。 ... [详细]
  • 本文探讨了在使用Selenium进行自动化测试时,由于webdriver对象实例化位置不同而导致浏览器闪退的问题,并提供了详细的代码示例和解决方案。 ... [详细]
  • 本文深入探讨了线性代数中向量的线性关系,包括线性相关性和极大线性无关组的概念。通过分析线性方程组和向量组的秩,帮助读者理解这些概念在实际问题中的应用。 ... [详细]
  • 本文介绍如何在 C++ 中使用链表结构存储和管理数据。通过具体示例,展示了静态链表的基本操作,包括节点的创建、链接及遍历。 ... [详细]
  • 本文旨在提供一套高效的面试方法,帮助企业在短时间内找到合适的产品经理。虽然观点较为直接,但其方法已被实践证明有效,尤其适用于初创公司和新项目的需求。 ... [详细]
  • 本文探讨了使用C#在SQL Server和Access数据库中批量插入多条数据的性能差异。通过具体代码示例,详细分析了两种数据库的执行效率,并提供了优化建议。 ... [详细]
  • 在跨浏览器开发中,一个常见的问题是关于如何在鼠标悬停时显示图片提示信息。本文深入探讨了 IE 浏览器对 IMG 元素 alt 属性的特殊处理,并提供了最佳实践建议。 ... [详细]
  • 反向投影技术主要用于在大型输入图像中定位特定的小型模板图像。通过直方图对比,它能够识别出最匹配的区域或点,从而确定模板图像在输入图像中的位置。 ... [详细]
  • 本问题探讨了在特定条件下排列儿童队伍的方法数量。题目要求计算满足条件的队伍排列总数,并使用递推算法和大数处理技术来解决这一问题。 ... [详细]
  • 本文由杨勇和思远于2012年12月27日撰写,主要探讨了如何使用PHP进行网页内容抓取,特别是针对字符较多的网站。文章详细介绍了正则表达式失效的原因,并提供了优化方法,同时展示了如何抓取淘宝服饰栏、天气信息以及IP地址对应的地理位置。 ... [详细]
  • 丽江客栈选择问题
    本文介绍了一道经典的算法题,题目涉及在丽江河边的n家特色客栈中选择住宿方案。两位游客希望住在色调相同的两家客栈,并在晚上选择一家最低消费不超过p元的咖啡店小聚。我们将详细探讨如何计算满足条件的住宿方案总数。 ... [详细]
  • 利用 Jest 和 Supertest 实现接口测试的全面指南
    本文深入探讨了如何使用 Jest 和 Supertest 进行接口测试,通过实际案例详细解析了测试环境的搭建、测试用例的编写以及异步测试的处理方法。 ... [详细]
  • 近期参与了一个旨在提高在线平台大规模查询响应速度的项目,预计处理的数据量为2-3亿条,数据库并发量约为每秒1500次,未来可能增至3000次。通过对比Redis和MongoDB,最终选择了MongoDB,因其具备优秀的横向扩展性和GridFS支持下的Map/Reduce功能。 ... [详细]
author-avatar
xuncijins
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有