xkm
xkm

Reputation: 271

Generating String ObjectId with GAE

What is the safe way to generate a ObjectId with String represnetation that will not collide in a distributed environment like Google App Engine (GAE) using Java?

Upvotes: 0

Views: 53

Answers (2)

kblomster
kblomster

Reputation: 91

Do you need the actual key to be a string or do you just need a string representation of it under some circumstances? This answer might be relevant in the latter case: How to convert an integer to the shortest url-safe string in Python?

Upvotes: 0

tj-recess
tj-recess

Reputation: 1809

How about using java UUID? You can do a quick check for collision by fetching the newly generated ID.

Upvotes: 1

Related Questions