|
Posted by Markus on 07/15/07 17:46
petersprc schrieb:
> With MyISAM, you can do one of the methods you described or use LOCK
> TABLES.
>
> In your case I would do ON DUPLICATE KEY UPDATE or remove the unique
> constraint on the id.
>
> Finally, if you need to prevent more than one thread from executing
> the generate function, you can use a semaphore with the key being your
> id.
Thank you, I will remove the primary key then. As I never heard of
semaphores before, I read about them in Wikipedia; it is an interesting
concept. Before I realized I could remove the unique constraint (and not
aware of LOCK TABLES being available for MyISAM), I had even thought of
some kind of locking mechanism, adding a "locked" field to the items
table, that a thread could set to 1 in order to lock the item, and back
to 0 in order to unlock it. This would be kind of a binary semaphore
emulation for a non-OO environment such as PHP 4.
Navigation:
[Reply to this message]
|