# ":database\_manager =\>CGI::Session::MemoryStore" doesn't work

**URL:** <https://www.ruby-forum.com/t/database-manager-cgi-memorystore-doesnt-work/95620>\
**Category:** Rails\
**Created:** [June 7, 2006, 5:11pm UTC](https://www.ruby-forum.com/t/database-manager-cgi-memorystore-doesnt-work/95620 "2006-06-07T17:11:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [June 7, 2006, 5:11pm UTC](https://www.ruby-forum.com/t/database-manager-cgi-memorystore-doesnt-work/95620/1 "2006-06-07T17:11:28Z")

</div>

Hi,

We are try to use the “database\_manager  
=\>CGI::Session::MemoryStore” for the session  
management. our website has a lot of “redirect\_to”.  
while the website is running under webrick, everything  
is fine. But when we run the system under  
aprache/fcgi. the redirect\_to seems doesn’t work  
anymore with the option “MemoryStore”

does anyone have the same problem, or have any idea  
about this???

Thanks you very much!!!

Saiho

The mind is its own place, and in itself.  
Can make a Heaven of Hell, a Hell of Heaven.

> **[Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos](https://www.yahoo.com/)**
>
> Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[Yahoo Mail - Organized Email](https://mail.yahoo.com)**
>
> It's time to get stuff done with Yahoo Mail. Just add your Gmail, Outlook, AOL or Yahoo Mail to get going. We automatically organize all the things life throws at you, like receipts and attachments, so you can find what you need fast. Plus, we've got...

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [June 7, 2006, 5:46pm UTC](https://www.ruby-forum.com/t/database-manager-cgi-memorystore-doesnt-work/95620/2 "2006-06-07T17:46:26Z")

</div>

On 6/7/06, Saiho Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

MemoryStore is local to the ruby process. So if you have more than one  
fcgi listener, you will have separate MemoryStores for each process,  
which will generally break applications that use sessions. The only  
time MemoryStore is workable is if you are using Webrick or  
fcgi/scgi/mongrel with a single listener, which is generally not the  
case in production. Try one of the other session storage options.

Jeremy

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [June 8, 2006, 5:18pm UTC](https://www.ruby-forum.com/t/database-manager-cgi-memorystore-doesnt-work/95620/3 "2006-06-08T17:18:58Z")

</div>

Hi Jeremy,

First, thanks you very much for the information!!!

However, in our case, we have a hugh object stored in  
the session variable, since each time we receive a  
html request, rails will serialize and deserialize the  
session obj. It is a very time consumming task.

We have take a look on the session storage option, the  
only one (we find) which does not serialize object is  
the memoryStore…

Does it exist another way that will not serializes the  
session object???

Thanks you very much

Saiho

— Jeremy E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 
> 
> sessions. The only  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

The mind is its own place, and in itself.  
Can make a Heaven of Hell, a Hell of Heaven.

> **[Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos](https://www.yahoo.com)**
>
> Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[\[object](https://mail.yahoo.com/)**
>
> \[object

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [June 8, 2006, 9:44pm UTC](https://www.ruby-forum.com/t/database-manager-cgi-memorystore-doesnt-work/95620/4 "2006-06-08T21:44:37Z")

</div>

On Thu, 2006-06-08 at 08:16 -0700, Saiho Y. wrote:

> Hi Jeremy,
> 
> First, thanks you very much for the information!!!
> 
> However, in our case, we have a hugh object stored in  
> the session variable, since each time we receive a  
> html request, rails will serialize and deserialize the  
> session obj. It is a very time consumming task.

You probably are coming from Java where you would just store an object  
in the session temporarily as you worked on it. Correct?

> We have take a look on the session storage option, the  
> only one (we find) which does not serialize object is  
> the memoryStore…
> 
> Does it exist another way that will not serializes the  
> session object???

Yes, don’t store anything in the session store. Store the object in the  
database just like normal, even though it’s “partially built”. Keep a  
field of this object to indicate it’s “stage” or “state” so that if  
someone stops half through you can continue where they left off.

Then, the only thing you really could store in the session is an integer  
indicating what object they are working on at that moment.

–  
Zed A. Shaw

> **[Zed A. shaw](https://zedshaw.com/)**
>
> Personal essays and writings by Zed A. Shaw.

[http://mongrel.rubyforge.org/](http://mongrel.rubyforge.org/)

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [June 8, 2006, 6:57pm UTC](https://www.ruby-forum.com/t/database-manager-cgi-memorystore-doesnt-work/95620/5 "2006-06-08T18:57:27Z")

</div>

On 6/8/06, Saiho Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> session object???  
> The only thing I can think of that would allow you to share memory  
> between processes and not serialize session objects is to create a new  
> session store type using SystemVIPC’s SharedMemory class [1] or mmap  
> [2]. That may work if all processes are on the same Unix/Linux/BSD  
> machine. I’m guessing it will require a C extension, if not changes  
> to the ruby interpreter itself, because of memory layout and garbage  
> collection issues. See POSH [3] for an example of a Python extension  
> that does something similar to what I am talking about.

IMO, it is probably a better idea to rearchitect your application so  
that serialization isn’t an issue. Or you could try fixing Rails so  
that it is thread safe, so you could use one process to serve multiple  
requests. Both would probably be easier than trying to get multiple  
ruby processes to share objects in memory without serialization.

Jeremy

[1] [http://deisui.org/~ueno/ruby/sysvipc.html](http://deisui.org/~ueno/ruby/sysvipc.html)  
[2] [http://moulon.inra.fr/ruby/mmap.html](http://moulon.inra.fr/ruby/mmap.html)  
[3] [http://poshmodule.sourceforge.net/](http://poshmodule.sourceforge.net/)

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [June 9, 2006, 4:47pm UTC](https://www.ruby-forum.com/t/database-manager-cgi-memorystore-doesnt-work/95620/6 "2006-06-09T16:47:35Z")

</div>

Thanks you very much for the information:)!!!

— Jeremy E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > only one (we find) which does not serialize object  
> > is to create a new  
> > that does something similar to what I am talking  
> > ruby processes to share objects in memory without  
> > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

The mind is its own place, and in itself.  
Can make a Heaven of Hell, a Hell of Heaven.

> **[Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos](https://www.yahoo.com)**
>
> Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[\[object](https://mail.yahoo.com/)**
>
> \[object

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [June 9, 2006, 4:12pm UTC](https://www.ruby-forum.com/t/database-manager-cgi-memorystore-doesnt-work/95620/7 "2006-06-09T16:12:25Z")

</div>

Hi Zed,

Thanks for the information:)!!!

> You probably are coming from Java where you would  
> just store an object  
> in the session temporarily as you worked on it.  
> Correct?

yes:)

> session is an integer  
> indicating what object they are working on at that  
> moment.

I wonder if I store the session obj in the a database,  
presently, I change the storage mode to  
ACtiveRecordStore, I wonder if the data is serialize  
then put into the field, or it is in binaire mode???

do you have a guess?

Thanks you very much again:)

Saiho

The mind is its own place, and in itself.  
Can make a Heaven of Hell, a Hell of Heaven.

> **[Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos](https://www.yahoo.com)**
>
> Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[\[object](https://mail.yahoo.com/)**
>
> \[object
