Re: create a method that only one user can access in the same time

2009-09-30 Thread gustavo Cardoso
Thanks a lot Dan, It's exactly what I was looking for. It was so easy. Now I can see. Thanks Again. On Wed, Sep 30, 2009 at 3:50 PM, Dan Ostrowski wrote: > > Sounds like you need an atomic operation. > > Instead of doing a SELECT, do an UPDATE and then check the affected > rows, such as: > > U

Re: create a method that only one user can access in the same time

2009-09-30 Thread Dan Ostrowski
Sounds like you need an atomic operation. Instead of doing a SELECT, do an UPDATE and then check the affected rows, such as: UPDATE table SET flag = 1 WHERE flag = 0; Then check if the operation succeeded. Cheers, Dan On Sep 30, 11:38 am, gustavo Cardoso wrote: > Acctually, > > I need to do

Re: create a method that only one user can access in the same time

2009-09-30 Thread gustavo Cardoso
Acctually, I need to do a SELECT in a table. In this table has a flag field. if the flag field has 0 so I can update de flag field to 1. In other words I need to do a SELECT by verifing if the flag field is 0. And after, I can update to 1 the flag field. But the problem is: More than one access o

Re: create a method that only one user can access in the same time

2009-09-30 Thread Kristaps Kūlis
Create locks and store them at cache as keys. Or implement counter as cache.incr('users_online') On Wed, Sep 30, 2009 at 3:52 AM, Nan wrote: > > Any particular reason you can't just use User.objects.count() ? > > On Sep 29, 7:16 pm, gustavo Cardoso wrote: > > Hello Folks, > > > > I need to impl

Re: create a method that only one user can access in the same time

2009-09-29 Thread Nan
Any particular reason you can't just use User.objects.count() ? On Sep 29, 7:16 pm, gustavo Cardoso wrote: > Hello Folks, > > I need to implement a Counter. > One variable to store the number of users in my site. > This variable can't be access in the same time for more than one user. > How I do