如果已为实体自动生成已删除的实体ID,那么App Engine再次可以使用吗? [英] Are deleted entity IDs once again available to App Engine if auto-generated for an Entity?

查看:146
本文介绍了如果已为实体自动生成已删除的实体ID,那么App Engine再次可以使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时候,我会在放置数据存储区实体之前分配一个ID,而有时我会允许App Engine自动生成ID.

Sometimes I allocate an ID before putting a datastore entity and other times I allow app engine to auto-generate the ID.

我的问题是:如果我放置一个实体然后将其删除,那么在分配和/或允许应用引擎为新实体自动生成ID时,该ID是否再次变为可用?

My question is: If I put an entity and then delete it, does the ID once again become available when allocating and/or allowing app engine to auto-generate an ID for a new entity?

我问的原因是我可能还有其他引用该ID的实体(有点像密钥),因此即使删除实体后,我也不希望ID可以回收.我目前通过仅删除实体而不在实体上放置已删除"标志来解决此问题.想知道这是如何工作的.

The reason I ask is I may have other entities referencing that ID (kind of like a key), so I do not want the ID's to be recycled even after an entity is deleted. I currently solve this by just never deleting entities but putting a "deleted" flag on them. Wondering how this works though.

推荐答案

我不会依赖ID的不重复使用-没有明确记录.另请参阅(相反) Google App Engine(数据存储)-删除的密钥会重新生成吗?.

I wouldn't rely on the non-reuse of the IDs - it is not explicitly documented. See also (the opposite) Google App Engine (datastore) - will a deleted key regenerate?.

如果您对保留实体不满意,我建议在实际删除实体并开放以供潜在重用之前,实施一种清理所有孤立引用的逻辑.无论如何这都不是一件坏事-这些孤立的引用可能会引起您的悲伤.

If you're not happy with keeping the entities around I'd suggest implementing a logic for cleaning up all the orphan references before actually deleting the entities and opening up for potential re-use. It wouldn't be a bad thing anyways - those orphan references could potentially cause you grief.

这篇关于如果已为实体自动生成已删除的实体ID,那么App Engine再次可以使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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