Definition
MongoDB\Model\CollectionInfo::getCappedSize()Return the size limit for the capped collection in bytes. This correlates with the
sizeoption forMongoDB\Database::createCollection().function getCappedSize(): integer|null
Return Values
The size limit for the capped collection in bytes. If the collection is not capped, null will be returned.
Examples
$db = (new MongoDB\Client)->test; // Creates a capped collection with a size of 1048576 $db->createCollection( 'myCappedCollection', ['capped' => true, 'size' => 1048576] ); // Retrieves the size limit for the capped collection foreach ($db->listCollections(['filter' => ['name' => 'myCappedCollection']]) as $info) { var_dump($info->getCappedSize()); }
The output would then resemble:
int(1048576)
See Also
Capped Collections in the MongoDB manual
listCollections command reference in the MongoDB manual