---
title: "创建capped collection"
author: "dikar"
date: "2011-05-20T09:23:53Z"
tags: ["MongoDB"]
categories: ["编程语言"]
slug: "capped-collection"
draft: false
lastmod: "2011-05-20T09:23:53Z"
id: 1051232
url: "https://dikar.iteye.com/blog/1051232"
---

记录下使用mongo 或者morphia 创建限额的collection

 

 

mongoDB

```
DBObject options = new BasicDBObject();
options.put("capped", true);
options.put("size", 100000);
options.put("max", 100);

DBCollection coll = db.createCollection("test", options);
```

 

 

 

morphia

```
@Entity(noClassnameStored=true,cap=@CappedAt(count=100,value=10000))
```