Forum: Ruby on Rails Global Hash?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
21c26386eabccd11f40c029b0ebf94e7?d=identicon&s=25 Brian Ablaza (zakifataya)
on 2007-01-22 22:14
I am working on a remote control slideshow app. Basically, there is a
control URL, and viewers point at a different URL to see the slides.
When the controller changes the slide, all viewers are updated.

The viewer contains an ajax periodic updater which loads javascript to
change some img src's.

Multiple shows can be run at once. I might be watching show 'foo' at
www.slideshow.com/foo/ while you're watching show 'baz' at
www.slideshow.com/baz/.

In order to maintain the current state of a given show, I need to store
the value of the current slide for that show. I'm imagining a hash with
showname, currentslide pairs. When I start a new 'foo' show, a new hash
is created with a 'foo' -> 1 pair (at the start of a show, the slide is
no. 1 by default).

There are an average of 50 simultaneous viewers, each refreshing every 2
seconds.

Questions:

- Should my currentslide info be stored in aDB? Seems like a big hammer
for a small problem.

- No one seems to like global variables. But would they work here?

- I'm trying to keep this in RAM for performance. It looks like
Madeleine will work for this, but is that overkill, too? For a 100 slide
show, I'd have 100 snapshots. If I ran that show 100 times, I'd have
10,000 snapshots. The API page for Madeleine is down, as is Pervayer's
page. Are there commands to purge stale or unneeded snapshots?

- All I really need is a simple hash kept in RAM, accessible across
multiple HTTP invocations. Suggestions?
2f9a03aa0fcfe945229cb6126eda2cb2?d=identicon&s=25 Philip Hallstrom (Guest)
on 2007-01-22 22:23
(Received via mailing list)
> - All I really need is a simple hash kept in RAM, accessible across
> multiple HTTP invocations. Suggestions?

http://www.danga.com/memcached/
This topic is locked and can not be replied to.