On Thu, 15 Dec 2005, Mariano K. wrote:
I am from a Java background and pretty new to Ruby and Rails.
What I am wondering is how I would shared state accross requests and users
without involving IO, i.e. use memory.
there are several ways, not all related to rails:
- use the database. a good db running on a box with battery backed
not goint to hit disk that often. even when it does, caching is
of the database.
- use shared memory. using systemvipc in ruby is trivial.
- use memory. if you have fastcgi configured for session affinity
ensure that all request travel to the same fastcgi process which,
case you didn’t know, are persistent. therefore a simple
persist data between requests.
- use drb. this elimiates the need for session affinity and makes
available even after the web servers has stopped and restarted.
uses a unix domain socket the data exchange is very fast, adding
small memcopy in kernel space.
My current understanding is that for each request a new process ist spawn
and therefore it gets its own memory. So no sharing can take place between
nope. fastcgi is persistent - http://fastcgi.com.
Do I understand this right? For those who know Java, let me rephrase that
to prevent missunderstandings?
Is there any equivalent to using the Application Context in J2EE, a
Singleton or static class members to store objects?
the simple answer is that, under fastcgi, ALL classes have this