Are deleted entity IDs once again available to App

2019-08-19 08:15发布

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.

2条回答
聊天终结者
2楼-- · 2019-08-19 09:12

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.

查看更多
该账号已被封号
3楼-- · 2019-08-19 09:19

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.

查看更多
登录 后发表回答