Assign dynamic (incrementable) values to objects


#1

I am working on a registration form for users.
Users can sign up to attend some sport events and are automatically
assigned a starting number depending on the users type.

There are several types of users and all have a specific range of
starting numbers.

0001 - 0050: not automatically assigend
0051 - 0600: type 1
0601 - 0650: type 2
1000 - 1300: type 3

What would be the best practice, to assign these values to a user and
increment the right counter?

Storing these values in a database table might be a little tricky.
I also could save the configuration in a yaml file, load it from there
and write it back. But what about multiple reads and writes at the
same time. Can this be handled by a message queue, which ensures that
the file (or database table) is sequentially accessed?

Thanks for any comment!