I need to create a small hash of values that persists across requests in Rails. I cannot store this information in the database or filesystem and only want to do it in memory. I was looking for a simple solution to implement this and read somewhere that memcache is pretty much overkill. This app is only running on one server so putting in memory should be just fine. I'm very new to rails and ruby and have attempted to implement a class variable like @@cache in my controller and that didn't work. I've also attempted to create a singleton class (include Singleton) outside of the controller and that didn't work either. Here is the singleton class that I created to cache the information. Any help would be appreciated. Thanks.
This would work as long as you have a *single* app server. As soon as you have two or more then they won't be able to share this information and you have syncing problems... which I'm guessing from below is going to matter to you (for a cached list of states say it wouldn't).
Memcache isn't hard to setup and does exactly what you want -- but keep in mind it's not persistant (meaning if it fills up, it will remove old entries).
Why can't you use the database or /tmp files?