|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
I'm trying to keep a live inventory on my company's website.
Anyway, this is the deal. If I have 4 copies of certain title on inventory, and person A adds it all 4 copies to his shopping cart. I want to keep a "temporary inventory" kinda thing that when person B logs and tries to find that book, it will show it like a out of stock book (but just temporarely) with a message saying that the book is temporarely unavailable, but to check back shortly to see if Person A abandon his/her shopping cart, in that case, the books would go back to the inventory and would be available again. I dont have a clue on how to approach this problem. I looked into it , and got some info about using cflock, but I'm not very familiar with that... can somebody help me?? Thank you ![]() |
|
#2
|
|||
|
|||
|
CFLOCK is for single-threading access to a piece of code and doesn't have anything to do with your issue, as far as I can tell.
Personally if this were me, I would let whoever BUYS the items first get them, not necessarily just who adds them to their cart first. Overall, what you are asking for will be difficult to implement. You could add another field to the database for the product, maybe call it "visibleInventory" which would normally be the same as inventory, until someone adds the product to their cart. Then this visibleInventory is altered to show the number of items the user added to the cart. When the user actually buys the itmes, the real inventory column is updated and it will match the visibleInventory column (unless someone else added the item to their cart in between the update)...the point being the real inventory will always be "catching up" with the visibleInventory. The problem arises when the user DOESN'T buy the items and just lets their session expire. There is no "onSessionExpire" that you could use to run code that would add back the items to the visibleInventory column. You'd have to do this manually, perhaps with a scheduled task. I suppose the message is that this will probably be difficult to do. Does this happen often enough that it's really a problem? The easier option might be to have a more reliable and efficient inventory restocking system.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
This is why I mention the cflock.
http://livedocs.macromedia.com/cold...1.htm#wp1100787 If you look at the example at the bottom, you will understand why I mentioned it. But tks for your reply |
|
#4
|
|||
|
|||
|
No, you definitely don't want to try to use CFLOCK to handle this situation, all you would do is create a gigantic bottleneck in your application. CFLOCK works like this:
Say I have code that does this (in pseudocode): user uploads a file named myfile. server saves myfile. server reads myfile and displays it back to the user. So far so good. But what happens if 2 users try to do this at the same time? user A uploads a file named myfile. user B uplaods a file named myfile. server saves myfile from A. server saves myfile from B. server reads myfile (from B!) and displays back to A. server reads myfile (from B!) and displays back to B. CFLOCK will prevent this by single-threading access to the code. user A uploads myfile, and initiates a lock on the rest of the code. user B uploads a file named myfile. server saves myfile from A. user B encounters the lock that A placed on the code and waits for release of lock. server reads myfile (from A) and displays back to A lock is released. server saves myfile from B. server reads myfile (from B) and displays back to B. Locking is necessary in cases like this, but as you can see the price is a bottleneck because all other threads are waiting for the lock to be released. |
|
#5
|
|||
|
|||
|
tks
![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > live inventoy |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|