笔记-capped collection
笔记-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的更多相关文章
- MongoDB整理笔记のCapped Collection
1.简单介绍 capped collections 是性能出色的有着固定大小的集合,以LRU(Least Recently Used 最近最少使用)规则和插入顺序进行age-out(老化移出)处理,自 ...
- Mongodb学习笔记(二)Capped Collection固定集合
一.Capped Collection固定集合 简单介绍 capped collections是性能出色的有着固定大小的集合(定容集合),以LRU(Least Recently Used最近最少使用) ...
- 基于mongoDB的capped collection的性能优化
MonitorLogging改造(消息接入) 改造前架构: 可以看出原来的流程中,大量业务分析,业务接入耦合在web服务层.大量操作,导致线程线性的挂起线程. 改造后: 将业务通讯抽象成为Monito ...
- MongoDB-固定集合 capped collection 操作 介绍
固定集合:capped collection 是性能出色的固定大小的集合,以LRU算法淘汰记录,自助维护集合中的对象的插入顺序,创建时预先制定大小,空间使用完,心对象取代旧的对象,保持最新的数据. 可 ...
- 关于MongoDB 固定集合(capped collection)的知识梳理
一 . 什么是固定集合 MongoDB中有一种特殊类型的集合,值得我们特别留意,那就是固定集合(capped collection). 固定集合可以声明collection的容量大小,其行为类似于循环 ...
- MongoDB 之 Capped Collection
MongoDB 支持 Capped Collection,一种固定大小的集合,当集合的大小达到指定大小时,新数据覆盖老数据,MongoDB Replica set 中的 oplog 就是 Capped ...
- MongoDB固定集合(capped collection)
一 . 什么是固定集合 MongoDB中有一种特殊类型的集合,值得我们特别留意,那就是固定集合(capped collection). 固定集合可以声明collection的容量大小,其行为类似于循环 ...
- mongoDB 固定集合(capped collection)
固定集合(Capped Collection)是一种尺寸固定的“循环”集合,可提供高效的创建.读取.删除等操作.这里所指的“循环”的意思是,当分配给集合的文件尺寸耗尽时,就会自动开始删除最初的文档,不 ...
- Mongodb Capped Collection集合
MongoDB 固定集合(Capped Collections)是性能出色且有着固定大小的集合,对于大小固定,我们可以想象其就像一个环形队列,当集合空间用完后,再插入的元素就会覆盖最初始的头部的元素! ...
随机推荐
- 旋转坐标+前缀和(zqu 25001)
本题题意:在一个矩阵中,去随机一点,设定一个步数K,求出从这个点可以走到的范围的和,求最大值 思路:这个范围的和是一个菱形,我们把他旋转45°,然后成为一个正放的矩阵,求出二维前缀和 然后用前缀和的性 ...
- C#中字符串常用方法
string str = "123@163.com"; int index = str.IndexOf('@'); // 返回3 从左向右第一个@ int index = str ...
- 基于maven+java+TestNG+httpclient+poi+jsonpath+ExtentReport的接口自动化测试框架
接口自动化框架 项目说明 本框架是一套基于maven+java+TestNG+httpclient+poi+jsonpath+ExtentReport而设计的数据驱动接口自动化测试框架,TestNG ...
- angular iframe 加载失效解决办法已经自适应高度
<iframe frameborder="0" id="iframe1"></iframe> $('#iframe1').attr('s ...
- Unity生成的WebGL如何在浏览器中运行
前言:以为在学完了COMP30019后,应该不会再接触Unity了,没想到之后实习让我去做把一个Unity项目转到WebGL,而关于Unity的WebGL资料很少,基本除了Unity的Manual就只 ...
- spring 中json使用
1.json序列化工具 public class JsonUtils { /** * Logger for this class */ private static final Logger logg ...
- 2、介绍在TensorFlow当中使用不同的方式创建张量tensor
import tensorflow as tf from tensorflow.python.framework import ops ops.reset_default_graph() #开始一个计 ...
- sping中AOP
委托代理的概念: 委托类对象就是我们后面说到的"目标对象", 也就是需要[被]代理的对象 target代理类对象就是我们后面说到的"代理对象",目标对象就是需要 ...
- Cygwin不能编译及解决办法
最近不知道什么原因,以前使用cygwin编译Android动态库,现在不能使用了,报下面的错误. Android NDK: Host 'awk' tool is outdated. Please de ...
- CentOS安装MySQL的步骤
1.下载 Mysql yum包 http://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/ 下载到本地再上传到服务器,或者使用wget 直接下载 w ...