有没有一种方法可以“释放”已分配的 ID?

huangapple go评论73阅读模式
英文:

Is there a way to "deallocate" id's that were allocated?

问题

让我们假设我已经使用allocateIdRange方法分配了一系列的ID块。是否有一种方法可以撤销这个操作?我对于分配大量ID而没有撤销方式感到紧张,有可能/意外地分配了一大段永远无法再次分配的ID。

英文:

Let's say I have allocated a block of IDs using the allocateIdRange method. Is there a way to undo this? I'm nervous about allocating large chunks of IDs without having a way to undo it and potentially/accidentally allocating a large range of IDs that will never be able to be allocated again.

答案1

得分: 1

Short Answer: 不,使用allocateIdRange方法后无法对ID进行“释放”。

Long Answer: 经过多次使用该方法的测试,我认为无法对这些ID进行“释放”。即使查看了Datastore的文档或App Engine API的文档以寻找可能的方法也是如此。

既然您担心分配了许多ID,然后无法再次分配它们,因为这些ID已经被保留,我只能说谨慎是最好的选择,因为库中没有内置的方法可以“释放”。

英文:

Short Answer: No, it is not possible to deallocate Ids after using allocateIdRange method.

Long Answer: After a lot of testing with this method, I think it is not possible to "deallocate" those IDs. Even looking at the docs for Datastore or the docs for the App Engine API for any possible methods.

Since you're concerned about allocating a lot and then not able to allocate again them because those are already reserved, I'll just say that being careful is the best option since there is no built-in method in the libs to deallocate.

答案2

得分: 0

我个人没有尝试过这个,但我认为你可以对想要“释放”的键执行删除操作。就像你通常删除实体一样。

英文:

I haven't tried this personally, but I would just think you could do a delete on the keys to wanted to 'deallocate'. Just as if you were deleting an entity in general.

huangapple
  • 本文由 发表于 2020年10月19日 22:54:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/64429891.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定