Are deleted entity IDs once again available to App Engine if auto-generated for an Entity?

半城伤御伤魂 提交于 2019-12-13 03:53:20

问题


Sometimes I allocate an ID before putting a datastore entity and other times I allow app engine to auto-generate the 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?

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.


回答1:


With the caveat that something may have changed since I was last involved with this (and a quick doc search turns up nothing new), my understanding is that once you allocate a block of IDs, they won't be recycled.




回答2:


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.



来源:https://stackoverflow.com/questions/46597750/are-deleted-entity-ids-once-again-available-to-app-engine-if-auto-generated-for

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!