The Cache Money page (http://github.com/nkallen/cache-money) mentions "For your unit tests, it is faster to use a Memcached mock than the real deal." Faster is fine but will it work with memcached? It doesn''t work with mine, I suspect the cache is not cleared between tests. I suspect this is just a documentation issue. This is a great GEM but it''s sad that documentation corrections are on various forums. :-\ One other question. to get it to work I needed to require memcache in my initializer. Anyone know why this is? Here it is (pieced together from various forums) require ''memcache'' require ''cache_money'' if RAILS_ENV == ''test'' $memcache = Cash::Mock.new else if RAILS_ENV != ''development'' config = YAML.load(IO.read(File.join(RAILS_ROOT, "config", "memcached.yml")))[RAILS_ENV] $memcache = MemCache.new(config) $memcache.servers = config[''servers''] $local = Cash::Local.new($memcache) $lock = Cash::Lock.new($memcache) $cache = Cash::Transactional.new($local, $lock) class ActiveRecord::Base is_cached :repository => $cache end else # If we''re in development mode, we don''t want to # deal with cacheing oddities, so let''s overrite # cache-money''s #index method to do nothing... class ActiveRecord::Base def self.index(*args) end end end end -- Posted via http://www.ruby-forum.com/.
On Sun, Nov 1, 2009 at 7:16 PM, Tony Primerano < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > The Cache Money page (http://github.com/nkallen/cache-money) mentions > > "For your unit tests, it is faster to use a Memcached mock than the real > deal." > > Faster is fine but will it work with memcached? It doesn''t work with > mine, I suspect the cache is not cleared between tests. I suspect this > is just a documentation issue. > > This is a great GEM but it''s sad that documentation corrections are on > various forums. :-\ > > One other question. to get it to work I needed to require memcache in > my initializer. Anyone know why this is? Here it is (pieced together > from various forums) > > require ''memcache'' > require ''cache_money'' > if RAILS_ENV == ''test'' > $memcache = Cash::Mock.new > else > if RAILS_ENV != ''development'' > config = YAML.load(IO.read(File.join(RAILS_ROOT, "config", > "memcached.yml")))[RAILS_ENV] > $memcache = MemCache.new(config) > $memcache.servers = config[''servers''] > > $local = Cash::Local.new($memcache) > $lock = Cash::Lock.new($memcache) > $cache = Cash::Transactional.new($local, $lock) > > class ActiveRecord::Base > is_cached :repository => $cache > end > else > # If we''re in development mode, we don''t want to > # deal with cacheing oddities, so let''s overrite > # cache-money''s #index method to do nothing... > class ActiveRecord::Base > def self.index(*args) > end > end > end > end >Hi, I would recommend taking a look at the following for proper use of: http://github.com/ngmoco/cache-money/blob/master/spec/memcached_wrapper_test.rb Good luck, -Conrad> -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Sun, Nov 1, 2009 at 7:51 PM, Conrad Taylor <conradwt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sun, Nov 1, 2009 at 7:16 PM, Tony Primerano < > rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > >> >> The Cache Money page (http://github.com/nkallen/cache-money) mentions >> >> "For your unit tests, it is faster to use a Memcached mock than the real >> deal." >> >> Faster is fine but will it work with memcached? It doesn''t work with >> mine, I suspect the cache is not cleared between tests. I suspect this >> is just a documentation issue. >> >>For properly clearing the cache before each test, you should reference the link below to create a suitable ''setup'' and ''teardown'' methods for your unit, functional, and integration tests.> This is a great GEM but it''s sad that documentation corrections are on >> various forums. :-\ >> >> One other question. to get it to work I needed to require memcache in >> my initializer. Anyone know why this is? Here it is (pieced together >> from various forums) >> >>In short, it''s part of the Rails application initialization process and it must be completed before the Rails application is ready for use. For example, if you take a look at the file in #{RAILS_ROOT}/config/initializers, you''ll see other files that are part of the application initialization process. Furthermore, this process usually takes place after the loading of both plugins and gems. Good luck, -Conrad> require ''memcache'' >> require ''cache_money'' >> if RAILS_ENV == ''test'' >> $memcache = Cash::Mock.new >> else >> if RAILS_ENV != ''development'' >> config = YAML.load(IO.read(File.join(RAILS_ROOT, "config", >> "memcached.yml")))[RAILS_ENV] >> $memcache = MemCache.new(config) >> $memcache.servers = config[''servers''] >> >> $local = Cash::Local.new($memcache) >> $lock = Cash::Lock.new($memcache) >> $cache = Cash::Transactional.new($local, $lock) >> >> class ActiveRecord::Base >> is_cached :repository => $cache >> end >> else >> # If we''re in development mode, we don''t want to >> # deal with cacheing oddities, so let''s overrite >> # cache-money''s #index method to do nothing... >> class ActiveRecord::Base >> def self.index(*args) >> end >> end >> end >> end >> > > Hi, I would recommend taking a look at the following for proper use of: > > > http://github.com/ngmoco/cache-money/blob/master/spec/memcached_wrapper_test.rb > > Good luck, > > -Conrad > > >> -- >> >> Posted via http://www.ruby-forum.com/. >> >> >> >> >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks for the pointers Conrad. It seems this project has several active forks on github. How does one go about choosing one? My hunch is to go with a fork that is still active but my fear is that it may diverge from what the original author intended and will become deprecated. Any recommendations here?
On Mon, Nov 2, 2009 at 4:58 AM, Tony <tony.primerano-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Thanks for the pointers Conrad. It seems this project has several > active forks on github. How does one go about choosing one? My hunch > is to go with a fork that is still active but my fear is that it may > diverge from what the original author intended and will become > deprecated. > > Any recommendations here? >Hi, I would recommend getting the version from http://www.gemcutter.org/gems/ngmoco-cache-money -Conrad> > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Nov 2, 8:13 am, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Mon, Nov 2, 2009 at 4:58 AM, Tony <tony.primer...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Thanks for the pointers Conrad. It seems this project has several > > active forks on github. How does one go about choosing one? My hunch > > is to go with a fork that is still active but my fear is that it may > > diverge from what the original author intended and will become > > deprecated. > > > Any recommendations here? > > Hi, I would recommend getting the version from > > http://www.gemcutter.org/gems/ngmoco-cache-money > > -ConradIt looks like these newer versions don''t bother with the initializer making the setup easier (i guess test cases us the mock by default). At the moment I am using ashleym1972-cache-money-0.2.9 as ngmoco gives the following error gem install ngmoco-cache-money ERROR: could not find gem ngmoco-cache-money locally or in a repository I have the following sources. gem sources *** CURRENT SOURCES *** http://gems.rubyforge.org/ http://gems.github.com
On Mon, Nov 2, 2009 at 7:16 AM, Tony <tony.primerano-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Nov 2, 8:13 am, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On Mon, Nov 2, 2009 at 4:58 AM, Tony <tony.primer...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Thanks for the pointers Conrad. It seems this project has several > > > active forks on github. How does one go about choosing one? My hunch > > > is to go with a fork that is still active but my fear is that it may > > > diverge from what the original author intended and will become > > > deprecated. > > > > > Any recommendations here? > > > > Hi, I would recommend getting the version from > > > > http://www.gemcutter.org/gems/ngmoco-cache-money > > > > -Conrad > > It looks like these newer versions don''t bother with the initializer > making the setup easier (i guess test cases us the mock by default). > > At the moment I am using ashleym1972-cache-money-0.2.9 as ngmoco gives > the following error > > gem install ngmoco-cache-money > ERROR: could not find gem ngmoco-cache-money locally or in a > repository > > I have the following sources. > gem sources > *** CURRENT SOURCES *** > > http://gems.rubyforge.org/ > http://gems.github.com > > > >Hi, you''ll need to install gemcutter gem and update your primary gem host by doing the following: sudo gem install gemcutter gem tumble Good luck, -Conrad> > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---