# Two peculiarities with Rails.cache.fetch()

**URL:** <https://www.ruby-forum.com/t/two-peculiarities-with-rails-cache-fetch/144270>\
**Category:** Rails\
**Created:** [July 28, 2008, 12:15am UTC](https://www.ruby-forum.com/t/two-peculiarities-with-rails-cache-fetch/144270 "2008-07-28T00:15:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![robb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a183cd/32.png) [@robb](https://www.ruby-forum.com/u/robb)\
**Post date:** [July 28, 2008, 12:15am UTC](https://www.ruby-forum.com/t/two-peculiarities-with-rails-cache-fetch/144270/1 "2008-07-28T00:15:14Z")

</div>

Hi,

I’m experimenting with using this inside of models which provide  
mostly static data from the database.

However, both cases where I wanted to use it, it seems to not work;  
I’m not sure if it’s me, or the library:

1. To save a boolean value. For example:

Rails.cache.fetch("#{cache\_key}.has\_children")  
{ self.has\_children? }

In the case of a ‘false’ result, this seems to always result in a  
cache miss the next time. I’m guessin that the logic of fetch() is  
such that it tests for success, not simply for “nil”?

1. To save ActiveRecords. I find that upon pulling them out of the  
cache, they don’t behave as expected. IOW, some methods aren’t found.

Thanks for any input,  
Robb
