design pattern to expire documents on cloudant

后端 未结 2 1200
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-18 15:54

So when a document is deleted, the metadata is actually preserved forever. For a hosted service like cloudant, where storage costs every month, I instead would like to compl

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-18 16:47

    Cloudant does not expose the _purge endpoint (the loose consistency guarantees between the clustered nodes make purging tricky).

    The most common solution to this problem is to create a second database and use replication with a validate_document_update so that deleted documents with no existing entry in the target database are rejected. When replication is complete (or acceptably up-to-date if using continuous replication), switch your application to use the new database and delete the old one. There is currently no way to rename databases but you could use a virtual host which points to the "current" database.

    I'd caution that a workload which generates a high ratio of deleted:active documents is generally an anti-pattern in Cloudant. I would first consider whether you can change your document model to avoid it.

提交回复
热议问题