method

read

read(key, options = nil)
public

No documentation available.

# File activesupport/lib/active_support/cache/mem_cache_store.rb, line 61
      def read(key, options = nil) # :nodoc:
        super
        @data.get(key, raw?(options))
      rescue MemCache::MemCacheError => e
        logger.error("MemCacheError (#{e}): #{e.message}")
        nil
      end

1Note

Confusing log output

kratob ยท Aug 13, 20101 thank

If you do a single Rails.cache.read('my_key'), your will usually see in your log something like

Cache read: my_key
Cache read: my_key
Cache write: my_key

Don't worry about this.

What happens here is this: Before going to memcached, rails will first ask a local MemoryStore cache (which is responsible for the first and third line in the log), before falling through to memcached. This local cache is destroyed after each request.

Source is in +activesupport/lib/active_support/cache/strategy/local_cache.rb+.