Posted By: Eric Hodel
Date: 2006-01-18 07:44
Summary: memcache-client and cached_model
Project: RC Tools

Two new releases added which help make the websites of The Robot Co-op go fast.

memcache-client is a much faster memcached client than Ruby-memcache (beware if you have both installed with Rails, I don't know what happens). cached_model stores ActiveRecord objects in memcache for speedy retrieval.

Enjoy!

Latest News
icalendar 1.4.0 Released
    Ryan Ahearn - 2013-05-21 23:17
BinData 1.5.0 - source moved to github
    Dion Mendel - 2013-05-21 11:10
v13.5.0 Released !!
    id 774 - 2013-05-18 12:28
Runt v0.9.0 Released
    Matthew Lipper - 2013-05-17 00:11
kramdown 1.0.2 released
    Thomas Leitner - 2013-05-09 06:58

 

Forums | Admin

Discussion Forums: memcache-client-and-cached_model

Start New Thread Start New Thread

 

By: Ron Mayer
Incorrect results with no error shown. [ reply ]  
2006-04-06 19:28
I think the script below gives incorrect results.
It seems what's happening is that the library doesn't want to write large values into the cache; so after attempting to set the new value into the cache I still read out the old results.

I would have liked either the setting expression to throw an exception or return a detectable value (nil? an error class?) or something like that.

An easy workaround is to use set() which happily returns an error value; and the workaround I ended up with simply rewrites []= to detect the error message from set.


require 'lib/memcache'; require 'timeout'
c = MemCache.new;
c.servers='localhost:11211'
a100k = (1..100_000).to_a
a1m = (1..1000_000).to_a
c['big']=a100k; puts c['big'].length # puts 100000, good
c['big']=a1m ; puts c['big'].length # puts 100000, BAD!