class Sass::FileCacheStore

A backend for the Sass cache using the filesystem.

def _retrieve(key, version, sha)

Other tags:
    See: {CacheStore#\_retrieve\_} -
def _retrieve(key, version, sha)
  return unless File.readable?(path_to(key))
  contents = nil
  File.open(path_to(key), "rb") do |f|
    if f.readline("\n").strip == version && f.readline("\n").strip == sha
      return f.read
    end
  end
  File.unlink path_to(key)
  nil
rescue EOFError, TypeError, ArgumentError => e
  Sass::Util.sass_warn "Warning. Error encountered while reading cache #{path_to(key)}: #{e}"
end

def _store(key, version, sha, contents)

Other tags:
    See: {CacheStore#\_store\_} -
def _store(key, version, sha, contents)
  return unless File.writable?(File.dirname(@cache_location))
  return if File.exists?(@cache_location) && !File.writable?(@cache_location)
  compiled_filename = path_to(key)
  return if File.exists?(File.dirname(compiled_filename)) && !File.writable?(File.dirname(compiled_filename))
  return if File.exists?(compiled_filename) && !File.writable?(compiled_filename)
  FileUtils.mkdir_p(File.dirname(compiled_filename))
  File.open(compiled_filename, "wb") do |f|
    f.puts(version)
    f.puts(sha)
    f.write(contents)
  end
end

def initialize(cache_location)

Parameters:
  • cache_location (String) -- see \{#cache\_location}
def initialize(cache_location)
  @cache_location = cache_location
end

def path_to(key)

Returns:
  • (String) - The path to the cache file.

Parameters:
  • key (String) --
def path_to(key)
  File.join(cache_location, key)
end