Shared memory multiprocesses
- by poly
I'm building an multi processes application and I need to save session ID, the sessions ID is 32 bit, and of course it can't be used twice in its lifetime, I'm currently using DB that saves all the ID in a table, and I do the following,
ID table is (int key, char used(1)) //1 is used, 0 is not
1. lock table
2. get one key for one sessions
3. update used field in it to used
4. unlock
After the session is finished the process use below to free key,
1. lock table
2. update used field in it to not used
4. unlock
I'm really wondering whether this is a good/fast implementation. and please note it's multi processes application.