BraveDave
2007-Mar-07 18:29 UTC
Agile Rails - How long does the Depot application hold onto the "Cart" array?
I''m walking through the wonderful "Agile Web Development for Rails" and in Chapter 8 on page 95 they build a Session model that has a physical table in the database and a "Cart" array that''s linked to the unique Session id. So if the session key was an integer 123 the cart array must have a ''foreign key'' value for the session_id = 123. The session is a ''real'' database table in the MySQL database while the cart is an array that''s linked by it''s ''foreign key'' named session_id. (This is the only way I can figure that it can hold the array?) My question is: This thing is stateless anyway...when (or does it ever) is the Cart array DUMPED from memory? Is it when the user logs off his browser? Is it after a certain time defined by the program? Is it after a certain time defined by the browser? What mechanism eventually dumps this array? Thank you, David --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dave Thomas
2007-Mar-07 18:59 UTC
Re: Agile Rails - How long does the Depot application hold onto the "Cart" array?
On Mar 7, 2007, at 12:29 PM, BraveDave wrote:> The session is a ''real'' database table in the MySQL database while the > cart is an array that''s linked by it''s ''foreign key'' named session_id. > (This is the only way I can figure that it can hold the array?) > My question is: This thing is stateless anyway...when (or does it > ever) is the Cart array DUMPED from memory? > Is it when the user logs off his browser? > Is it after a certain time defined by the program? > Is it after a certain time defined by the browser? > What mechanism eventually dumps this array?At the end of each request, all references to it disappear, and Ruby will eventually garbage collect it. A new cart object is constructed for every incoming request on the session. Cheers Dave --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---