一般に、グローバル キャッシュには、グローバル変数、定数、またはクラス インスタンス変数のどちらが適していますか?
それぞれの例を次に示します。
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