Join us at MongoDB.local London on 7 May to unlock new possibilities for your data. Use WEB50 to save 50%.
Register now >
Docs Menu
Docs Home
/ /

MongoDB\Model\CollectionInfo::getCappedSize()

Obsoleto desde la versión 1.9.

MongoDB\Model\CollectionInfo::getCappedSize()

Devuelve el límite de tamaño para la colección con tamaño fijo en bytes. Esto se correlaciona con la opción size para MongoDB\Database::createCollection().

function getCappedSize(): integer|null

El límite de tamaño para la colección con tamaño fijo en bytes. Si la colección no es limitada, se devolverá null.

Este método está en desuso a favor de usar MongoDB\Model\CollectionInfo::getOptions() y acceder a la clave size.

<?php
$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());
}

La vista de salida se ilustraría como sigue:

int(1048576)
  • MongoDB\Model\CollectionInfo::getCappedMax()

  • MongoDB\Model\CollectionInfo::isCapped()

  • MongoDB\Database::createCollection()

  • colección con tamaño fijo en el manual de MongoDB

  • Referencia del comando listCollections en el manual de MongoDB

Volver

obtenerCapppedMax()

En esta página