I am analysis memcache. Hence would like to know whats the best client
for memcache. Have read a lot about memcache-client gem. Is that the
most popular and widely used one?
Also most of my queries are complex queries and i have used find_by_sql
for the same. Can i cache these results got from find_by_sql?
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.:
I had the configuration :
config.cache_store = :mem_cache_store
in my specific environment file.
Still i was getting the above mentioned error
Yani Yen wrote:
> Hi,
>
> What i did in my environment.rb file was created an instance of memcache
> and assign it to a constant:
>
> CACHE = MemCache.new('127.0.0.1')
>
> and then in my code something like this:
[snip]
Okay, that makes it clearer to me. I think you are starting two instances of
the cache client and the second one fails because the first is already present
and running. Try with just the
I have one more doubt. I want a write through cache mechanism. How to
enable that?
Is there some configuration?
Also, found that cache-money is a write through as well as read only
cache. I wanted to know how to configure it to behave as write through
ie, any new entry should first be made to cache and then to the backing
store. In my case the database.
The below configuration:
:readonly => false,
makes cache write enabled, but does it also write it to the backing
store?
Prachi,
I can't help you there, I've used memcache only for caching HTML fragments.
There are several fine tutorials on using memcache on the Web, including using
it to cache database records. Try railscasts.com, their screencasts are
excellent.