Created
April 14, 2011 17:33
-
-
Save aharbick/920015 to your computer and use it in GitHub Desktop.
If you drop a capped collection and re-create it with different size params then data files never get cleaned up.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pp' | |
@conn = Mongo::Connection.new | |
def randomString (string_length) | |
chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; | |
randomstring = ''; | |
0.upto(string_length) do | |
rnum = (rand * chars.size).floor | |
randomstring += chars.slice(rnum,rnum+1); | |
end | |
return randomstring; | |
end | |
@size = 10000000 | |
0.upto(100) do | |
@conn.db('capped_test').create_collection('capped', {:capped => true, :size => @size, :max => 10000}) | |
# Report storageSize and fileSize | |
pp "storageSize: #{@conn.db('capped_test').collection('capped').stats['storageSize']}" | |
pp "fileSize: #{@conn.db('capped_test').stats['fileSize']}" | |
pp "-----------------------------------" | |
# Save the current storageSize for next iteration through the loop | |
@size = @conn.db('capped_test').collection('capped').stats['storageSize'] | |
# Drop our collection | |
@conn.db('capped_test').collection('capped').drop() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment