Docs 菜单
Docs 主页
/ / /
PHP 库手册
/ / /

MongoDB\Model\CollectionInfo::getCappedMax()

自 1.9 版起已弃用

MongoDB\Model\CollectionInfo::getCappedMax()

返回固定大小集合的文档限制。 这与 MongoDB\Database::createCollection()max选项相关。

function getCappedMax(): integer|null

固定大小集合的文档限制。 如果集合未设定上限,则返回null

此方法已弃用,取而代之的是使用MongoDB\Model\CollectionInfo::getOptions()和访问max密钥。

<?php
$db = (new MongoDB\Client)->test;
// Creates a capped collection with a document limit of 100
$db->createCollection(
'myCappedCollection',
['capped' => true, 'size' => 1048576, 'max' => 100]
);
// Retrieves the document limit for the capped collection
foreach ($db->listCollections(['filter' => ['name' => 'myCappedCollection']]) as $info) {
var_dump($info->getCappedMax());
}

而输出将类似如下所示:

int(100)
  • MongoDB\Model\CollectionInfo::getCappedSize()

  • MongoDB\Model\CollectionInfo::isCapped()

  • MongoDB\Database::createCollection()

  • MongoDB 手册中的固定大小集合

  • MongoDB 手册中的listCollections命令参考

后退

CollectionInfo

在此页面上