Method: PEROBS::Store#_new_id
- Defined in:
- lib/perobs/Store.rb
#_new_id ⇒ Integer
Internal method. Don’t use this outside of this library! Generate a new unique ID that is not used by any other object. It uses random numbers between 0 and 2**64 - 1.
521 522 523 524 525 526 527 528 529 530 531 532 |
# File 'lib/perobs/Store.rb', line 521 def _new_id @lock.synchronize do begin # Generate a random number. It's recommended to not store more than # 2**62 objects in the same store. id = rand(2**64) # Ensure that we don't have already another object with this ID. end while @in_memory_objects.include?(id) || @db.include?(id) id end end |