设计模式以使cloudant上的文档过期 [英] design pattern to expire documents on cloudant

查看:60
本文介绍了设计模式以使cloudant上的文档过期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,当删除文档时,元数据实际上会永久保留。对于像cloudant这样的托管服务,每月需要支付存储费用,我想彻底清除已删除的文档。

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 completely purge the deleted documents.

我读过某处关于设计模式的地方,您在其中使用 dbcopy ,以将文档放入当前数据库,然后定期删除过期的db。但是我找不到这篇文章,而且我不太了解数据库命名的工作原理。 cloudant客户端将如何始终知道当前数据库名称?

I read somewhere about a design pattern where you use dbcopy in a view to put the docs into a 'current' db then periodically delete the expired dbs. But I cant find the article, and I don't quite understand how database naming would work. How would the cloudant clients always know the 'current' database name?

推荐答案

Cloudant不公开_purge端点(宽松的一致性)

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

此问题最常见的解决方案是创建第二个数据库,并使用带有validate_document_update的复制,以便删除没有目标数据库中的现有条目将被拒绝。复制完成后(如果使用连续复制,则为最新状态),将您的应用程序切换为使用新数据库并删除旧数据库。当前无法重命名数据库,但是您可以使用指向当前数据库的虚拟主机。

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.

我警告说,工作负载会产生很高的负担。删除:活动文档的比例通常是Cloudant中的反模式。我首先考虑是否可以更改文档模型来避免这种情况。

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.

这篇关于设计模式以使cloudant上的文档过期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆