module Opal::Cache

def fetch(cache, key, &block)

def fetch(cache, key, &block)
  # Extension to the Sprockets API of Cache, if a cache responds
  # to #fetch, then we call it instead of using #get and #set.
  return cache.fetch(key, &block) if cache.respond_to? :fetch
  key = digest(key.join('/')) + '-' + runtime_key
  data = cache.get(key)
  data || begin
            compiler = yield
            cache.set(key, compiler) unless compiler.dynamic_cache_result
            compiler
          end
end