# Agile Rails - How long does the Depot application hold onto

**URL:** <https://www.ruby-forum.com/t/agile-rails-how-long-does-the-depot-application-hold-onto/88051>\
**Category:** Rails\
**Created:** [March 7, 2007, 7:33pm UTC](https://www.ruby-forum.com/t/agile-rails-how-long-does-the-depot-application-hold-onto/88051 "2007-03-07T19:33:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bravedave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/46a35a/32.png) [@bravedave](https://www.ruby-forum.com/u/bravedave)\
**Post date:** [March 7, 2007, 7:33pm UTC](https://www.ruby-forum.com/t/agile-rails-how-long-does-the-depot-application-hold-onto/88051/1 "2007-03-07T19:33:31Z")

</div>

I’m walking through the wonderful “Agile Web D. 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

---

<div class="post-metadata">

**Author:** ![bravedave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/46a35a/32.png) [@bravedave](https://www.ruby-forum.com/u/bravedave)\
**Post date:** [March 7, 2007, 8:06pm UTC](https://www.ruby-forum.com/t/agile-rails-how-long-does-the-depot-application-hold-onto/88051/2 "2007-03-07T20:06:42Z")

</div>

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
