I was using a PHP mongo command:
$db->command(array("create" => $name, "size" => $size, "capped" => true, "max" => $max));
And my collections grew way past their supposed capped limits. I put on a fix:
$db->createCollection($name, true, $size, $max);
Currently, the counts are so low I can’t tell whether the ‘fix’ worked.
How can you tell if a collection is capped, either from the shell or PHP? I wasn’t able to find this information in the system.namespaces.
In the shell, use db.collection.stats(). If a collection is capped:
If a collection is not capped, the “capped” key will not be present.
Below are example results from stats() for a capped collection:
This is with MongoDB 1.7.4.