问题
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:
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.
来源:https://stackoverflow.com/questions/42093436/google-app-engine-datastore-will-a-deleted-key-regenerate