[英]confusion about mongodb capped collection
I am new to mongodb. 我是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. 对于
db.getCollection("user")
,如果存在一个名为“ user”的现有集合,它将返回该集合。 If "user" does not exit, getCollection("user")
will create a new collection. 如果“ user”没有退出,则
getCollection("user")
将创建一个新集合。 Now I want to know what type of collection does getCollection
create. 现在,我想知道
getCollection
创建哪种收集类型。 Does getCollection
return a capped collection? getCollection
是否返回有上限的集合?
I have read mongodb manual: 我已经阅读了mongodb手册:
You must create capped collections explicitly using the
createCollection()
method.您必须使用
createCollection()
方法显式创建带上限的集合。
Does this mean the collection created by getCollection
is not capped collection? 这是否意味着由
getCollection
创建的集合不是上限集合?
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). 除了通过您描述的技术(它可以通过API或Shell创建)之外,MongoDB不会创建有上限的集合。
Max default size for a collection? 集合的最大默认大小? Around 2GB on a 32 bit system.
在32位系统上约为2GB。 However, 10gen does not recommend the 32bit build for a production system (see here).
但是,10gen不建议将32位版本用于生产系统(请参见此处)。
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/ . Mongodb封顶的集合有很多限制,请参阅链接http://docs.mongodb.org/manual/core/capped-collections/ 。 I would recommend TTL rather which helps achieve the same aim.
我建议使用TTL,而不是帮助实现相同的目标。 You can find more about TTL here http://docs.mongodb.org/manual/tutorial/expire-data/ .
您可以在http://docs.mongodb.org/manual/tutorial/expire-data/中找到有关TTL的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.