I have data that gets loaded from text files, then parsed into specific
data structures. I need this data to be persistent within the Rails
universe available to every request that comes into Rails.
I’m used to a web dev language Lasso where there is a true persisent
in-memory environment surrounding all requests. Using globals (with some
read/write thread locking) is a great way to create an in-memory cache
for many-reads/occasional-writes.
I can’t seem to recreate this in Rails. I attempted to use global var
like I would in Lasso, but so far that hasn’t proven effective. The var
appears to get recreated (some confusion about the meaning of “global”
there, but that may be another topic).
I have caught wind of memcached, but that sounds like overkill for my
needs (this Rails app will only ever need to run on a single machine).
Actually, I’ll have several machines, but each needs it’s own cache for
this data–unique per machine which again is why the global thing was
perfect in Lasso.
Then there’s the issue of making this data available to multiple
instances of mogrel/Rails. Lasso is multi-threaded, so there was no need
to deal with starting an arbitrary number of handlers like is needed
with Rails.
Anyway, is there a way to create such a critter in Rails, or is
memcached the only option?
– gw