Re: shortening the cart
This WebDNA talk-list message is from 1998
It keeps the original formatting.
numero = 18290
interpreted = N
texte = At 6:23 AM 6/17/98, Peter Ostry wrote:>You have to generate it on your own.>Cart numbers can be shorter than 7 digits so I guess the easiest way is to>generate a long number and use the first 7 digits:>[GetChars start=1&end=7][cart][cart][/GetChars]The problem with this approach is that you'll end up with many duplicatecart numbers over the course of a day. A WebCat cart number is simply thedate (expressed as days since 00/00/0000) concantinated with the time(seconds since midnight) and number of ticks. So, by taking the first sevendigits, you'd be getting the date portion (which is six digits in 1998) andthe first digit of the time. Thus, there are only 10 possible cart valuesfor each day, each one possibly being used many times during the day. (seePeter's related post entitled calculating unique time)A more secure approach would be to use the time as base for your cartnumbers. Assuming you're expiring the carts in a reasonably short periodof time, I would generate the seven-digit number as follows:[Date %w][format .5d][math]{[Time %H:%M:%S]}[/math][/format][format1s][math][random]-1[/math][/format][Date %w] is the day of the week (1 digit), [format .5d][math]{[Time%H:%M:%S]}[/math][/format] is the time since midnight (5 digits), and[format 1s][math][random]-1[/math][/format] is a random number (1 digit).This will give you (theoretically) up to 10 unique carts per second andallows you to keep your carts for up to a week. If you are expiring cartsafter 24 hours, you can get rid of the [Date %w] and move from a 1-digitrandom number to a 2-digit random number, which gives a theoretical limitof 100 unique carts per second.An alternate approach is to keep a database with all of your cart numbers(or even just the most recently assigned cart number). To generate a newcart, you do a search for the greatest cart number in the database and addone to that number (and be sure to update the database). You can start thesequence at whatever number you want and not worry about duplicates untilit rolls over.-Daveo--------------- Dave MacLeay --+o----------- Digital Frontier --+o--- dave@digitalfrontier.com --+
Associated Messages, from the most recent to the oldest:
At 6:23 AM 6/17/98, Peter Ostry wrote:>You have to generate it on your own.>Cart numbers can be shorter than 7 digits so I guess the easiest way is to>generate a long number and use the first 7 digits:>[GetChars start=1&end=7]
[cart][cart][/GetChars]The problem with this approach is that you'll end up with many duplicatecart numbers over the course of a day. A WebCat cart number is simply thedate (expressed as days since 00/00/0000) concantinated with the time(seconds since midnight) and number of ticks. So, by taking the first sevendigits, you'd be getting the date portion (which is six digits in 1998) andthe first digit of the time. Thus, there are only 10 possible cart valuesfor each day, each one possibly being used many times during the day. (seePeter's related post entitled calculating unique time)A more secure approach would be to use the time as base for your cartnumbers. Assuming you're expiring the carts in a reasonably short periodof time, I would generate the seven-digit number as follows:[Date %w][format .5d]
[math]{[Time %H:%M:%S]}[/math][/format][format1s]
[math][random]-1[/math][/format][Date %w] is the day of the week (1 digit), [format .5d]
[math]{[Time%H:%M:%S]}[/math][/format] is the time since midnight (5 digits), and[format 1s]
[math][random]-1[/math][/format] is a random number (1 digit).This will give you (theoretically) up to 10 unique carts per second andallows you to keep your carts for up to a week. If you are expiring cartsafter 24 hours, you can get rid of the [Date %w] and move from a 1-digitrandom number to a 2-digit random number, which gives a theoretical limitof 100 unique carts per second.An alternate approach is to keep a database with all of your cart numbers(or even just the most recently assigned cart number). To generate a newcart, you do a search for the greatest cart number in the database and addone to that number (and be sure to update the database). You can start thesequence at whatever number you want and not worry about duplicates untilit rolls over.-Daveo--------------- Dave MacLeay --+o----------- Digital Frontier --+o--- dave@digitalfrontier.com --+
Dave MacLeay
DOWNLOAD WEBDNA NOW!
Top Articles:
Talk List
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...
Related Readings:
Follow-Up to: Removing [showif] makes a big difference in speed (1997)
New public beta available (1997)
Re:Merging databases (1997)
international time (1997)
Search Question (2003)
WebCatb15 Mac CGI -- [purchase] (1997)
Sorting (2005)
[Sum] function? (1997)
Help name our technology! I found it (1997)
Show shoppingcart after remove last item (1997)
problem: mail changed (1997)
Serving images from databases (1998)
PIXO (1997)
Re2: AAgghh!! Help, please. SSL strikes again. (1997)
Upgrading old WebCat Database Files (1997)
IE Cache Problems... (1999)
Listing Words Backwords (2001)
Problems with [Applescript] (1997)
wc 2 pro users - sites, quotes wanted (1997)
[WebDNA] checking for mixed case text (2009)