class ODBA::IdServer

Constants

ODBA_EXCLUDE_VARS
ODBA_SERIALIZABLE

Public Class Methods

new() click to toggle source
# File lib/odba/id_server.rb, line 12
def initialize
        @ids = {}
end

Public Instance Methods

next_id(key, startval=1) click to toggle source
# File lib/odba/id_server.rb, line 15
def next_id(key, startval=1)
        @mutex ||= Mutex.new
        res = nil
        @mutex.synchronize { 
                @ids[key] ||= (startval - 1)
                res = @ids[key] += 1
        }
        odba_store
        res
end