I was wondering lately. Why doesn''t AR cache it''s lookups in memory? What I mean is at least maintaining a hash of loaded records by their ID through the request processing cycle. I am sure it was considered but rejected at some point - I would love to know why. -- Julian "Julik" Tarkhanov
Hi Julian - there are some rails extensions to do this in Michael Schuerig''s ''Boilerplate'' framework: http://www.schuerig.de/michael/boilerplate/ The stuff you''re looking for is "Enumerations". Cheers! -DF On 10/23/05, Julian ''Julik'' Tarkhanov <listbox-RY+snkucC20@public.gmane.org> wrote:> I was wondering lately. Why doesn''t AR cache it''s lookups in memory? > > What I mean is at least maintaining a hash of loaded records by their > ID through the request processing cycle. > I am sure it was considered but rejected at some point - I would love > to know why. > -- > Julian "Julik" Tarkhanov > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Wowz that Boilerplate framework is very cool stuff :) ----- Original Message ----- From: "David Felstead" <david.felstead-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> Sent: Monday, October 24, 2005 9:04 AM Subject: Re: [Rails] Why no flyweight in AR? Hi Julian - there are some rails extensions to do this in Michael Schuerig''s ''Boilerplate'' framework: http://www.schuerig.de/michael/boilerplate/ The stuff you''re looking for is "Enumerations". Cheers! -DF On 10/23/05, Julian ''Julik'' Tarkhanov <listbox-RY+snkucC20@public.gmane.org> wrote:> I was wondering lately. Why doesn''t AR cache it''s lookups in memory? > > What I mean is at least maintaining a hash of loaded records by their > ID through the request processing cycle. > I am sure it was considered but rejected at some point - I would love > to know why. > -- > Julian "Julik" Tarkhanov > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On Monday 24 October 2005 09:04, David Felstead wrote:> Hi Julian - there are some rails extensions to do this in Michael > Schuerig''s ''Boilerplate'' framework:My understanding is that Julian is looking for something different. Namely what Fowler calls an Identity Map. The purpose is to have at most one canonical instance of each domain object. Say you''re executing MyModel.find(...) twice with different options. Then, with ActiveRecord, you may get multiple instances of what is logically the same object (same id). An identity map resolves multiple equivalent instances to a single canonical one. Michael -- Michael Schuerig I am the sum total of the parts mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org I control directly. http://www.schuerig.de/michael/ --Daniel C. Dennett, Elbow Room
On 24-okt-2005, at 12:25, Michael Schuerig wrote:> On Monday 24 October 2005 09:04, David Felstead wrote: > >> Hi Julian - there are some rails extensions to do this in Michael >> Schuerig''s ''Boilerplate'' framework: >> > > My understanding is that Julian is looking for something different. > Namely what Fowler calls an Identity Map. The purpose is to have at > most one canonical instance of each domain object. Say you''re > executing > MyModel.find(...) twice with different options. Then, with > ActiveRecord, you may get multiple instances of what is logically the > same object (same id). An identity map resolves multiple equivalent > instances to a single canonical one.Yes Michael, thanks for correcting me. What I was actually meaning is "why I need to install and hack cacheAR if AR could do it by itself?" This would also releave some memory. -- Julian "Julik" Tarkhanov
> Yes Michael, thanks for correcting me. What I was actually meaning is > "why I need > to install and hack cacheAR if AR could do it by itself?" This would > also releave some memory.Why? Because it hasn''t been a big enough thorn in the side of someone to write a patch for it. I''ve been wanting something like this too, but it hasn''t been a big enough issue yet. Suggestion: write a plugin for it. If it works well, maybe it''ll make it into rails core? -- rick http://techno-weenie.net
On Monday 24 October 2005 15:10, Rick Olson wrote:> > Yes Michael, thanks for correcting me. What I was actually meaning > > is "why I need > > to install and hack cacheAR if AR could do it by itself?" This > > would also releave some memory. > > Why? Because it hasn''t been a big enough thorn in the side of > someone to write a patch for it. I''ve been wanting something like > this too, but it hasn''t been a big enough issue yet.I see a problem there and I can''t say how big it is. In Rails, not all instances of a logical object are created equal. Through "piggy-backing" objects may acquire attributes that are not present as columns in the database table. Join table attributes are a case where ActiveRecord does this automatically. When you amend a query with additional columns in the :select option you can get the same effect. Michael -- Michael Schuerig There is no matrix, mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org only reality. http://www.schuerig.de/michael/ --Lawrence Fishburn