Method: Helper::CacheLoader.load
- Defined in:
- lib/helper.rb
.load(path, options = DEFAULT_OPTIONS) ⇒ Object
ファイルの更新時刻を考慮してファイルのデータを取得する。前回取得した時からファイルが変更されていない場合は、キャッシュを返す
options にはファイルを読み込む時に File.read に渡すオプションを指定できる
462 463 464 465 466 467 468 469 470 471 472 473 474 |
# File 'lib/helper.rb', line 462 def load(path, = DEFAULT_OPTIONS) @@mutex.synchronize do fullpath = File.(path) cache_data = @@caches[fullpath] if Helper.file_latest?(fullpath) || !cache_data body = File.read(fullpath, ) @@caches[fullpath] = body return body else return cache_data end end end |