笔记-capped collection

1.      collection

1.1.    简介

集合分为固定与非固定collection,capped collection

1.1.1.   capped collections

Capped collections are fixed-size collections that support high-throughput operations that insert and retrieve documents based on insertion order. Capped collections work in a way similar to circular buffers: once a collection fills its allocated space, it makes room for new documents by overwriting the oldest documents in the collection.

Capped collections 是固定大小的collection。它支持高速吞吐,这是基于插入顺序实现的。它的工作原理类似于循环缓冲区,一旦接近预定的存储空间限制,它会覆盖集合中最老的文档。

1.2.    CURD

1.2.1.   create

capped colletions 需要显示创建;使用createcollection方法

db.createCollection(<name>, { capped: <boolean>,

autoIndexId: <boolean>,

size: <number>,

max: <number>,

storageEngine: <document>,

validator: <document>,

validationLevel: <string>,

validationAction: <string>,

indexOptionDefaults: <document>,

viewOn: <string>,

pipeline: <pipeline>,

collation: <document>,

writeConcern: <document>} )

参数释义:

capped:

size:文档空间限制,单位是bytes;只对capped collection生效

max:用于限制文档数,使用时需注意与size的配合。

下面是一些案例:

db.createCollection( "log", { capped: true, size: 100000 } )

db.createCollection("log", { capped : true, size : 5242880, max : 5000 } )

1.2.2.   Updates

If you plan to update documents in a capped collection, create an index so that these update operations do not require a collection scan.

1.2.3.   delete

You cannot delete documents from a capped collection. To remove all documents from a collection, use the drop() method to drop the collection and recreate the capped collection.

capped collection不支持删除文档操作,清除所有文档的方法是drop()集合然后重新创建。

1.2.4.   document size

如果更新或替换操作会导致文档大小改变,操作会失败。

If an update or a replacement operation changes the document size, the operation will fail.

1.3.    其它操作

检查是否为capped集合

db.collection.isCapped()

转换普通集合为限制集合

db.runCommand({"convertToCapped": "mycoll", size: 100000});

笔记-capped collection的更多相关文章

  1. MongoDB整理笔记のCapped Collection

    1.简单介绍 capped collections 是性能出色的有着固定大小的集合,以LRU(Least Recently Used 最近最少使用)规则和插入顺序进行age-out(老化移出)处理,自 ...

  2. Mongodb学习笔记(二)Capped Collection固定集合

    一.Capped Collection固定集合 简单介绍 capped collections是性能出色的有着固定大小的集合(定容集合),以LRU(Least Recently Used最近最少使用) ...

  3. 基于mongoDB的capped collection的性能优化

    MonitorLogging改造(消息接入) 改造前架构: 可以看出原来的流程中,大量业务分析,业务接入耦合在web服务层.大量操作,导致线程线性的挂起线程. 改造后: 将业务通讯抽象成为Monito ...

  4. MongoDB-固定集合 capped collection 操作 介绍

    固定集合:capped collection 是性能出色的固定大小的集合,以LRU算法淘汰记录,自助维护集合中的对象的插入顺序,创建时预先制定大小,空间使用完,心对象取代旧的对象,保持最新的数据. 可 ...

  5. 关于MongoDB 固定集合(capped collection)的知识梳理

    一 . 什么是固定集合 MongoDB中有一种特殊类型的集合,值得我们特别留意,那就是固定集合(capped collection). 固定集合可以声明collection的容量大小,其行为类似于循环 ...

  6. MongoDB 之 Capped Collection

    MongoDB 支持 Capped Collection,一种固定大小的集合,当集合的大小达到指定大小时,新数据覆盖老数据,MongoDB Replica set 中的 oplog 就是 Capped ...

  7. MongoDB固定集合(capped collection)

    一 . 什么是固定集合 MongoDB中有一种特殊类型的集合,值得我们特别留意,那就是固定集合(capped collection). 固定集合可以声明collection的容量大小,其行为类似于循环 ...

  8. mongoDB 固定集合(capped collection)

    固定集合(Capped Collection)是一种尺寸固定的“循环”集合,可提供高效的创建.读取.删除等操作.这里所指的“循环”的意思是,当分配给集合的文件尺寸耗尽时,就会自动开始删除最初的文档,不 ...

  9. Mongodb Capped Collection集合

    MongoDB 固定集合(Capped Collections)是性能出色且有着固定大小的集合,对于大小固定,我们可以想象其就像一个环形队列,当集合空间用完后,再插入的元素就会覆盖最初始的头部的元素! ...

随机推荐

  1. Codeforces Round #608 (Div. 2)D(贪心)

    #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ],b[],c[]; int u,v; ...

  2. MySQL表的操作02

    [1]设置非空约束(NOT NULL ,NK)--->>>目的是f防止某些字段中的内容为空 CREATE TABLE +table_name ( 属性名   数据类型   NOT N ...

  3. 转载:AAC文件解析及解码

    转自:http://blog.csdn.net/wlsfling/article/details/5876016 http://www.cnblogs.com/gaozehua/archive/201 ...

  4. WEB前后端约定接口

  5. Bugku-CTF加密篇之贝斯家族(@iH<,{bdR2H;i6*Tm,Wx2izpx2!)

    贝斯家族 @iH<,{bdR2H;i6*Tm,Wx2izpx2!  

  6. Bug搬运工-CSCvn51483:AP datasheet should contain info if the AP contains or not temperature sensor

    目前在老一些的思科AP上,应该都没有温度传感器的功能(例如AP1600,wave 1 AP1700...),但是在思科官方没有明确的文档去说明这个问题. 在Outdoor AP(室外AP,例如AP15 ...

  7. Go语言基础之Path包与FilePath包

    文章引用自 path包的使用 package main; import ( "fmt" "path" ) //go语言path包的学习 func main() ...

  8. Rsync+inotify数据同步

    安装环境 备份服务器端:CentOS7,IP:192.168.1.100 备份客户端:CentOS7,IP:192.168.1.200 服务器端Rsync服务部署 1.安装程序包 # yum –y i ...

  9. Java编译器的常量优化

    /* 在给变量进行赋值的时候,如果右侧的表达式当中全都是常量,没有任何变量, 那么编译器javac将会直接将若干个常量表达式计算得到结果. short result = 5 + 8; // 等号右边全 ...

  10. Uva 11300 Spreading the Wealth(贪心)

    题目链接:https://vjudge.net/problem/UVA-11300 这道题的思路太神了,但很难想到是贪心. 用M表示每个人最终拥有的金币数. 首先假设有四个人.假设1号给2号3枚,2号 ...