Generic-user-small ramkaka 31 posts

Hey Mike,

The book says in page 160 to use

def cache_id(cache_id) 
cache_id 
end 

to use facebook_id instead of the id as the key in memcache.

But, when I use the code as is, I observe that my cache has two key-value pairs:
id => active_record
fb_uid => active_record. (This is created by User.for(...) on first call)

To verify this, I did the following:
u = User.find(1)
User.get_cache(1) == User.get_cache(u.facebook_id) (returns true

Am I missing something?

 
Head_small Mike Mangino 148 posts

I’m a little confused. Can you run memcached with -vvv to show what is being sent back and forth?

Mike

 
Generic-user-small ramkaka 31 posts

I’ll try that.

 
Generic-user-small ramkaka 31 posts

I am using cache_fu and it has a :find_by setting which when set to facebook_id resolved my problem.

 
Head_small Mike Mangino 148 posts

Thanks for pointing that out. I didn’t realize that the find_by method existed.

5 posts, 2 voices