ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old September 9th, 2004, 11:58 AM
cfgirl cfgirl is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 14 cfgirl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation live inventoy

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


Reply With Quote
  #2  
Old September 9th, 2004, 12:38 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,626 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 6 m 34 sec
Reputation Power: 53
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

Reply With Quote
  #3  
Old September 9th, 2004, 12:44 PM
cfgirl cfgirl is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 14 cfgirl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old September 9th, 2004, 01:25 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,626 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 6 m 34 sec
Reputation Power: 53
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.

Reply With Quote
  #5  
Old September 9th, 2004, 01:33 PM
cfgirl cfgirl is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 14 cfgirl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile

tks

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > live inventoy


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway