views:

11

answers:

0

For a RoR web project I am building the component stack. Because I want to share some cached business objects between requests and sessions of the same application I planned not to use the Rails/Mongrel shared nothing principle and switch over to JRuby for the first time. (No, I do not want an extra process like memcached). My idea so far is using one or more singleton classes to cache the objects I want to use across requests and sessions. On this evening's web travel I came across a lot of pages describing the different deployment scenarios, but nothing that pointed me to my intended direction. Hence the following four questions:

  1. Is the singleton pattern an acceptable practice in general or are there other techniques in such a scenario which are common sense and I simply don't know?
  2. Is there a way to code the shared singleton classes in Ruby as well, or is writing custom classes in Java to be called from Ruby the only option?
  3. How do I have to declare these classes in either way to instruct the application container to share them?
  4. Since I do not want to be specific to a certain deployment environment, i. e. application server, are there differences in realizing shared memory between various AS brands and versions I have to watch out for?

Any clues are highly appreciated. Thanks in advance! [ofi]