user94628
user94628

Reputation: 3721

MongoDB Capped Collection Maximum allowable size

I'm using a mongodb capped collection which is tailable. I want to set the size of it to a maximum value as I don't want to really have the oldest records removed according to the FIFO rule.

I want the data to pesist for as long as possible whilst keeping the features of a capped collection.

Thanks

Upvotes: 3

Views: 5642

Answers (2)

radtek
radtek

Reputation: 36270

You can create the capped collection using size (in bytes), or max (maximum number of documents to keep), or both in this case:

pymongo ->

self.db.create_collection('system_health_log', capped=True, size=5242880, max=5000)

mongo shell ->

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

See more here on Capped Collections.

Upvotes: 1

JohnnyHK
JohnnyHK

Reputation: 311835

You can make the capped collection as big as you want; just set the size parameter of create_collection to a value big enough to not run out of space.

Like this:

 db.create_collection('captest', capped=True, size=20000000000)

Upvotes: 8

Related Questions