There may be a better way to do it in rails, but in the general case, if
you want to have a bunch of processes the have some sort of shared
memory space available, make the bit that holds that memory a separate
process that everything talks to.

Generally, I'd probably go about it by having an object exposed over dRB
for the other processes to access - you'd have all the query methods
kept in that process so that only the query results are transmitted over
the wire, not all the data.

But from what you're talking about, I'd say the best way would be to
have that data in a database, have enough memory on your database box to
keep that table in memory (and possibly tune the database to force it
there regardless of what else it wants to keep in memory), and then use
it through activerecord/some other ORM/direct SQL. Databases are good at
that sort of thing. But then, I know very little about the data you want
there - if it doesn't map to db tables well, this might be hard.

> -----Original Message-----
> From: Tom [mailto:tlianza / gmail.com] 
> Sent: Friday, 11 November 2005 11:37 AM
> To: ruby-talk ML
> Subject: Application variable with Ruby on Rails
> 
> I've seen a few newsgroups that ask this question, but have 
> yet to find a good answer.  Does anyone know of a good way to 
> store a variable in memory that can be shared by all sessions 
> in Rails?  JSP/ASP/and I believe even ColdFusion have the 
> concept of an "Application variable"
> which you can populate at runtime and share amongst all 
> pages/sessions.
> 
> I've seen some say this can't be done, and others say that it 
> can with a reference to some homebrew caching mechanism.  Are 
> there any thoughts in this group?  I've seen several ways to 
> cache a page, but I don't want to do that - I simply want an 
> array stored in memory because I'm going to access it (for 
> reading) *a ton* and it's going to have the same data in it 
> for all users.  I will update it maybe every few minutes, but 
> plan on reading from it every few seconds or even more 
> frequently depending on traffic.
> 
> Thanks!
> Tom
> 
> P.S. On other groups I've seen this concept referred to as an 
> "application hash" or "global application variable".
> 
> 
> 
> ##############################################################
> #######################
> This email has been scanned by MailMarshal, an email content filter.
> ##############################################################
> #######################
> 
> 
#####################################################################################
This email has been scanned by MailMarshal, an email content filter.
#####################################################################################