Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unique Key Generation

 
Saidul Islam
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did anyone work on any unique key generation algorithm that is not based on timestamp? Maybe based on the combnation of timestamp and random numbers, or database driven or any other mechanishm.
Would you like to share your thoughts on this?
Forgive me if the question sounds not related to the forum. Maybe we can ask JavaRanch host to create a new forum for discussing algorithm/pattern in Java.
------------------
<b>JStar</b>
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a good question for this forum.
This is another thread that was discussing random number generation: http://www.javaranch.com/ubb/Forum33/HTML/001523.html
 
Steve Fahlbusch
Bartender
Posts: 602
7
Mac OS X Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of the ones I have used, I ususally generate some pseudounique
keys than bounce off of a file (database) of used keys and then
find a appropriatily close key. This is usually some form of
hashing. How it normally works:
hash the key
look up to see if hashed key is in use
if not, mark as hashed, save object id (or whatever)
if it is, look for next unused hash, mark as hashes save object id.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic