# Will method value be cached?

**URL:** <https://www.ruby-forum.com/t/will-method-value-be-cached/119253>\
**Category:** Rails\
**Created:** [November 5, 2007, 1:32pm UTC](https://www.ruby-forum.com/t/will-method-value-be-cached/119253 "2007-11-05T13:32:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/82dd89/32.png) [@xain](https://www.ruby-forum.com/u/xain)\
**Post date:** [November 5, 2007, 1:32pm UTC](https://www.ruby-forum.com/t/will-method-value-be-cached/119253/1 "2007-11-05T13:32:36Z")

</div>

Will method value be cached?

For example, in situation like this:

> class Book \< ActiveRecord::Base  
> def best\_book  
> Book.find(:first, :conditions =\> […])  
> end

> def open\_best\_book  
> best\_book.ready  
> best\_book.open  
> end

> def open  
> …

when the open\_best\_book method is called, how many times the Book.find  
function runs?

will rewrite the open\_best\_book method like below save time?

> def open\_best\_book  
> best\_book = Book.find(:first, :conditions =\> […])  
> best\_book.ready  
> best\_book.open  
> end
