Google App Engine (datastore) - will a deleted key

2019-07-11 12:31发布

I've got a simple question about datastore keys. If I delete an entity, is there any possibility that the key will be created again? or each key is unique and can be generated only one-time?

Thanks.

1条回答
时光不老,我们不散
2楼-- · 2019-07-11 13:07

It is definitely possible to re-use keys.

Easy to test, for example using the datastore admin page:

  • create an entity for one of your entity models using a custom/specified key name and some property values
  • delete the entity
  • create another one using the same key name and different property values...

As for the keys with auto-generated IDs it is theoretically possible, but I guess rather unlikely due to the high number of possibilities. From Assigning identifiers:

Cloud Datastore can be configured to generate auto IDs using two different auto id policies:

  • The default policy generates a random sequence of unused IDs that are approximately uniformly distributed. Each ID can be up to 16 decimal digits long.
  • The legacy policy creates a sequence of non-consecutive smaller integer IDs.
查看更多
登录 后发表回答