class Fontist::Utils::Cache
Constants
- MAX_FILENAME_SIZE
Public Class Methods
Source
# File lib/fontist/utils/cache.rb, line 58 def self.lock_path(path) "#{path}.lock" end
Public Instance Methods
Source
# File lib/fontist/utils/cache.rb, line 76 def already_fetched?(keys) map = load_cache keys.find { |k| cache_exist?(map[k]) } end
Source
# File lib/fontist/utils/cache.rb, line 81 def delete(key) lock(lock_path) do map = load_cache return unless map[key] value = map.delete(key) map.to_file(cache_map_path) value end end
Source
# File lib/fontist/utils/cache.rb, line 62 def fetch(key) map = load_cache if Fontist.use_cache? && cache_exist?(map[key]) print(map[key]) return downloaded_file(map[key]) end generated_file = yield path = save_cache(generated_file, key) downloaded_file(path) end
Source
# File lib/fontist/utils/cache.rb, line 92 def set(key, value) lock(lock_path) do map = load_cache map[key] = value map.to_file(cache_map_path) end end