Reply to Re: Mutex access on a database?

Your name:

Reply:


Posted by Gordon Burditt on 11/15/45 11:26

>Hello. I have a database which I have abstracted off with a set of
>functions I have written. (So all the correct quoting and unquoting are all
>in one place.)
>
>/* Simplified code. */
>
>$tokenCount = getTokenCount($userIdx);
>/* Context switch! */
>setTokenCount($userIdx, $tokenCount + 1);
>
>But what if another process perfoms a get on the same record between the
>get and the set of the first process? What I could do with is a mutex.
>
>Do they please exist for PHP running under Apache?

If you perform a query like:

update foo set bar=bar+1 where id = '$userIdx';

it should be atomic in the database without the need for explicit
locks, as it's all done in one SQL statement.

If your abstractions provide only the ability to read and write
things, not atomic increments and decrements, perhaps your design
needs changing.

Gordon L. Burditt

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация