Re: Sinister variable caching problem with rand()

2010-05-16 Thread Perrin Harkins
On Sat, May 15, 2010 at 9:48 PM, Anthony Esposito wrote: > The reason I am not using auto_increment is because the databases exist on a > mysql cluster. The auto_increment counts would have to be maintained very > carefully with multiple servers running the same database so I opted to not > worry

Re: Sinister variable caching problem with rand()

2010-05-16 Thread Clinton Gormley
> In an SQL server, you'd use a SEQUENCE: > > SELECT NEXT VALUE FOR MY_BLA_SEQ FROM <...> > Here's a good read about how Flickr manage their unique IDs using MySQL: http://code.flickr.com/blog/2010/02/08/ticket-servers-distributed-unique-primary-keys-on-the-cheap/ clint

Re: Sinister variable caching problem with rand()

2010-05-16 Thread Michael Ludwig
André Warnier schrieb am 16.05.2010 um 13:40:31 (+0200): > One alternative is to use some strictly incremental > counter, shared between multiple processes running on > potentially multiple systems or CPUs. This requires a > common place to store the counter, which survives a system > restart, an

Re: Sinister variable caching problem with rand()

2010-05-16 Thread André Warnier
Michael Ludwig wrote: André Warnier schrieb am 15.05.2010 um 22:47:14 (+0200): A tip : to get a really unique identifier, I often use "mmddhhmmssr", where r is the rand() result, and the prefix is the date/time. Unless you process more than 99,999 requests per second, it will always

Re: Sinister variable caching problem with rand()

2010-05-16 Thread Michael Ludwig
André Warnier schrieb am 15.05.2010 um 22:47:14 (+0200): > A tip : to get a really unique identifier, I often use > "mmddhhmmssr", where r is the rand() result, > and the prefix is the date/time. Unless you process more > than 99,999 requests per second, it will always be unique. I'm

Re: Sinister variable caching problem with rand()

2010-05-15 Thread Anthony Esposito
PS. I had to strengthen the srand() function I added to the startup.pl that Cosimo suggested. I used the example from the perldoc and have not had any duplicate keys so far. I was having upwards of 3 per 1000 when using srand(time ^ $$) Fix added to startup.pl file ---

Re: Sinister variable caching problem with rand()

2010-05-15 Thread Anthony Esposito
Thank you everyone for helping me, I am surprised by the support our there for mod_perl. Cosimo sent me a quick fix to add to the startup.pl file, I have tested and verified it. The code below works with no problems after adding: my $srv = Apache2::ServerUtil->server; $srv->push_handlers( PerlC

Re: Sinister variable caching problem with rand()

2010-05-15 Thread Michael Peters
On 05/15/2010 04:47 PM, André Warnier wrote: A tip : to get a really unique identifier Another tip: to get a really unique identifier use mod_unique_id or Data::UUID or the UUID() function in mysql. -- Michael Peters Plus Three, LP

Re: Sinister variable caching problem with rand()

2010-05-15 Thread Cosimo Streppone
On Sat, 15 May 2010 22:03:50 +0200, Anthony Esposito wrote: In one of my programs I started to receive database errors for not having a unique id. I generate unique ids for each of the mysql lines that I add to the database. I realized that the perl variable $idNum was keeping the same r

Re: Sinister variable caching problem with rand()

2010-05-15 Thread André Warnier
Adam Prime wrote: Perrin Harkins wrote: On Sat, May 15, 2010 at 4:03 PM, Anthony Esposito wrote: In one of my programs I started to receive database errors for not having a unique id. I generate unique ids for each of the mysql lines that I add to the database. I realized that the perl variab

Re: Sinister variable caching problem with rand()

2010-05-15 Thread Adam Prime
Perrin Harkins wrote: On Sat, May 15, 2010 at 4:03 PM, Anthony Esposito wrote: In one of my programs I started to receive database errors for not having a unique id. I generate unique ids for each of the mysql lines that I add to the database. I realized that the perl variable $idNum was keepin

Re: Sinister variable caching problem with rand()

2010-05-15 Thread Perrin Harkins
On Sat, May 15, 2010 at 4:03 PM, Anthony Esposito wrote: > In one of my programs I started to receive database errors for not having a > unique id. I generate unique ids for each of the mysql lines that I add to > the database. I realized that the perl variable $idNum was keeping the same > random