Re: Re: Memcache

Jeffrey L. Taylor
Mon, 19 Jul 2010 19:28:55 -0000

Quoting Yani Yen
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>:
> After reading through a lot of blogs, everyone seems to say that
> memcache-client seems to be faster and better.
>
> I installed memcache-client-1.8.5.gem
>
> And my configuration in environment.rb file is:
>
> memcache_options = {
>    :compression => true,
>    :debug => false,
>    :namespace => "mem-#{RAILS_ENV}",
>    :readonly => false,
>    :urlencode => false
> }
>
> memcache_servers = [ ''127.0.0.1:11211'' ]
>
> CACHE = MemCache.new(memcache_options)
> CACHE.servers = memcache_servers
>

In my application, all I do is add the following line to
conf/environments/production.rb and restart the server:

config.cache_store = :mem_cache_store

I only cache in production, caching in development is too error prone, I
change something and am getting the incorrect cached result instead of the new
corrected result.

The host and port defaults to 127.0.0.1:11211.  Start here, when that works,
get fancier, e.g.:

config.cache_store = :mem_cache_store, ''127.0.0.1:11211'', {
  :compression => true,
  :debug => false,
  :namespace => "mem-#{RAILS_ENV}",
  :readonly => false,
  :urlencode => false
}


HTH,
  Jeffrey