title: Caching File in a class variable in Ruby On Rails
body: <p>In my Rails application I need to query a binary file database on each page load. The query is read only. The file size is 1.4 MB. I have two questions:</p>
  
  <p>1) Does it make sense to cache the <code>File</code> object in a class variable? </p>
  
  <pre><code>def some_controller_action    
      @@file ||= File.open(filename, 'rb')
      # binary search in @@file
  end
  </code></pre>
  
  <p>2) Will the cached object be shared across different requests in the same rails process?</p>