Is there a was to specify to Rails that it should hold the contents of a table in memory? For instances, I have a lookup table that is a two column table (id and description) and then lots of things that belong_to those its. class A < ActiveRecord::Base belongs_to :lookup end I''d love to able to say a.lookup.description without needing another SQL call. I know you can avoid the call using the :include feature, but that means joins in the SQL backend, and I''m doing LOTS of these queries. Something like this would be great: class Lookup < ActiveRecord::Base :cache_table_in_memory end Then all operations on the Lookup class would be done in memory. It would also add a refresh method that you could manually call on the infrequent event where the lookup table changes. If something like this exists, can someone point me in the right direction? If not, consider it a feature suggestion. Thanks, Andrew --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Andrew Selder wrote:> > Is there a was to specify to Rails that it should hold the contents of > a table in memory? > > For instances, I have a lookup table that is a two column table (id and > description) and then lots of things that belong_to those its. > > class A < ActiveRecord::Base > > belongs_to :lookup > > end > > > > I''d love to able to say a.lookup.description without needing another > SQL call. I know you can avoid the call using the :include feature, but > that means joins in the SQL backend, and I''m doing LOTS of these > queries. > > Something like this would be great: > > class Lookup < ActiveRecord::Base > > :cache_table_in_memory > > end > > Then all operations on the Lookup class would be done in memory. It > would also add a refresh method that you could manually call on the > infrequent event where the lookup table changes. > > If something like this exists, can someone point me in the right > direction? If not, consider it a feature suggestion. > > Thanks, > > AndrewI hope you are aware of cached_model plugin on top of memcached by honourable drbrain aka Eric Hodel of Holy School of Seattle.rb. Now, of course, you can''t use the above plugin, if you are not running memcached. Still, quite a few DRb based caching mechanisms are sprouting all over the place. You can use, Bakcgroundrb to cache values or else you can use this: http://boogaloo.rubyforge.org/doc/ Or if you are unhappy with all the above shit, roll your own and have your name embodied in golden chapters of rails development forever. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Have a look at Trevor Squires enumerations mixin which allows you to treat instances of your ActiveRecord models as though they were an enumeration of values while caching Instances in memory. http://svn.protocool.com/rails/plugins/enumerations_mixin/trunk/ On 12/28/06, Hemant Kumar <gethemant-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Andrew Selder wrote: > > > > Is there a was to specify to Rails that it should hold the contents of > > a table in memory? > > > > For instances, I have a lookup table that is a two column table (id and > > description) and then lots of things that belong_to those its. > > > > class A < ActiveRecord::Base > > > > belongs_to :lookup > > > > end > > > > > > > > I''d love to able to say a.lookup.description without needing another > > SQL call. I know you can avoid the call using the :include feature, but > > that means joins in the SQL backend, and I''m doing LOTS of these > > queries. > > > > Something like this would be great: > > > > class Lookup < ActiveRecord::Base > > > > :cache_table_in_memory > > > > end > > > > Then all operations on the Lookup class would be done in memory. It > > would also add a refresh method that you could manually call on the > > infrequent event where the lookup table changes. > > > > If something like this exists, can someone point me in the right > > direction? If not, consider it a feature suggestion. > > > > Thanks, > > > > Andrew > I hope you are aware of cached_model plugin on top of memcached by > honourable drbrain aka Eric Hodel of Holy School of Seattle.rb. > > Now, of course, you can''t use the above plugin, if you are not running > memcached. Still, quite a few DRb based caching mechanisms are sprouting > all over the place. > > You can use, Bakcgroundrb to cache values or else you can use this: > http://boogaloo.rubyforge.org/doc/ > > Or if you are unhappy with all the above shit, roll your own and have > your name embodied in golden chapters of rails development forever. > > > > > >-- Never be afraid to try something new. Remember, amateurs built the ark; professionals built the Titanic! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---