title: Global variable vs. constant vs. class instance variable for global cache
body: <p>In general which is better for a global cache: global variable, constant, or class instance variable?</p>
  
  <p>Here is an example of each:</p>
  
  <pre><code>module Foo
    $FOO_CACHE = {}
    def self.access_to_cache
      $FOO_CACHE
    end
  end
  
  module Foo
    CACHE = {}
    def self.access_to_cache
      CACHE
    end
  end
  
  module Foo
    @cache = {}
    def self.access_to_cache
      @cache
    end
  end
  </code></pre>