I am new to mongodb. Here is a code snippet:
MongoClient mongo = new MongoClient("localhost", 27017);
DB db = mongo.getDB("testdb");
DBCollection collection = db.getCollection("user");
for db.getCollection("user")
, if there is an existing collection named "user", it will return this collection. If "user" does not exit, getCollection("user")
will create a new collection. Now I want to know what type of collection does getCollection
create. Does getCollection
return a capped collection?
I have read mongodb manual:
You must create capped collections explicitly using the
createCollection()
method.
Does this mean the collection created by getCollection
is not capped collection?
Also I want to know:
MongoDB does not create a capped collection except through the technique you describe (it could be created through an API or the shell).
Max default size for a collection? Around 2GB on a 32 bit system. However, 10gen does not recommend the 32bit build for a production system (see here).
Maximum number of collections is a bit more complex, and is best explained by the documentation .
Mongodb capped collection has so many restrictions, see the link http://docs.mongodb.org/manual/core/capped-collections/ . I would recommend TTL rather which helps achieve the same aim. You can find more about TTL here http://docs.mongodb.org/manual/tutorial/expire-data/ .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.