Saturday, December 18, 2010

Defer Deletion, Garbage Collection, and Bulk Undelete (using WIN + CouchDB)

I really, really, really hate providing the delete function. So, for WIN, I provide a delete that doesn't delete until 31 days have passed. It allows me to sleep at night and dream of unicorns.

I have an updator that will change the name space of the document and adds meta data to the document related to the deletion.

Then I provide a function to the environment to easily call the updator that looks and tastes like a delete:

Every day, I have a cron job that looks at this indexer

and it kills them one by one. Now, I know that actual deletes will be done in 31 (or so) days.

What if I need to undo? Well, it is very easy to undo one element. If I would like to undo a whole bunch, I have to provide a common key to un-delete from. That's what the action parameter does. If I write a loop that deletes a bunch of stuff, then I need to build a fairly unique key that enables me to undo that batch delete.

1 comment:

  1. This is great and I actually needed this for a current project. Nice one.