mongodb Capped Collections 固定集合
2016-08-16 12:07
861 查看
特点
像队列,插入的效率很高,size大小固定(还可以指定max限制文档个数),自动按照插入的顺序返回文档不能从capped集合中删除文档,只能整个集合一块删除
不能sharding
使用
When creating a capped collection you must specify the maximum size of the collection in bytes, which MongoDB will pre-allocate for the collection. The size of the capped collection includes a small amount of space for internal overhead.
db.createCollection( "log", { capped: true, size: 100000 } )
注意:
If the size field is less than or equal to 4096, then the collection will have a cap of 4096 bytes. Otherwise, MongoDB will raise the provided size to make it an integer multiple of 256.
指定文档个数
db.createCollection("log", { capped : true, size : 5242880, max : 5000 } )
使用natural操作符
可以让返回顺序变为插入的逆序db.cappedCollection.find().sort( { $natural: -1 } )
Check if a Collection is Capped
db.collection.isCapped()
Convert a Collection to Capped
db.runCommand({"convertToCapped": "mycoll", size: 100000});
Automatically Remove Data After a Specified Period of Time
consider MongoDB’s TTL indexes,see mongodb manual
相关文章推荐
- mongodb固定集合(Capped Collection)和大文件管理(GridFS)
- mongodb固定集合(Capped Collection)和大文件管理(GridFS)
- MongoDB:5-MongoDB的固定集合(capped collection)
- 关于MongoDB 固定集合(capped collection)的知识梳理
- 【MongoDB】Capped固定集合
- mongoDB应用篇——固定集合和GridFS文件
- MongoDB 分组统计,固定集合(五)
- MongoDB应用——Capped集合
- mongodb 中 Aggregation 的管道和分片集合( Pipeline and Sharded Collections)
- MongoDB基本概念(二):集合 Collections
- MongoDB Capped Collections
- mongodb capped collections
- Mongodb固定集合
- MongoDB 进阶(命令\固定集合)
- mongodb固定集合,建立管理员安全验证
- mongo 固定集合,大文件存储,简单优化 + 三招解决MongoDB的磁盘IO问题
- mongodb固定集合、TTL集合
- MongoDB笔记十二——固定集合
- MongoDB 学习笔记(五):固定集合、GridFS文件系统与服务器端脚本
- MongoDB Capped Collections