c# - Generating Unique 6-digit numbers per day -


i'm developing multi-process solution , have assign 6 digit unique numbers objects (specifying more 6 digits or using alphanumeric characters not possible. length of number third-party constraint).

since multi-process solution (multiple instances of application run @ same time), cannot depend on using lock shared variables in project , i'd prevent using shared storage (db/file system/...) maintain , generate these unique numbers.

also, it's highly unlikely need more 300,000 unique numbers per day.
there algorithm (probably dependent on time of day) can generate unique 6-digit numbers per day?

would possible divide groups of numbers give each thread? ie. if have total of 300 000 id numbers , 3 threads, can provide each thread interval work with.

thread 1 ->  1 - 99 9999  thread 2 ->  100 000 - 199 999  thread 3 ->  200 000 - 300 000 

you provide smaller intervals , thread gets assigned number of ids can use , when runs out has go , ask central id organizer new set of ids work with.

would like

while(hasworktodo) {   foreach(int uniqueid in getuniqueidintervalfromcentralidcontroller()) // 10000 ids @ time   {     //work globally unique id   } } 

if number of id's aren't abundant work out way hand unused ids main id controller (ie if thread requests 1000 ids uses 50 , finishes).


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -