Skip to content

class Crystal::CacheDir
inherits Reference

Manages cache files in the ".crystal" directory.

For each compiled program a directory is created in the cache that stores .bc and .o files that could possibly be reused from a previous compilation.

To keep the cache dir small, only the 10 most recently used directories are kept. We use the directory's modification time for this.

Class methods

.instance

View source

Methods

#cleanup

Keeps the 10 most recently used directories in the cache, and removes all others.

View source

#dir

Returns the cache directory.

View source

#directory_for(sources : Array(Compiler::Source))

Returns the directory where cache files related to the given sources will be stored. The directory will be created if it doesn't exist.

View source

#directory_for(filename : String)

Returns the directory where cache files related to the given filenames will be stored. The directory will be created if it doesn't exist.

View source

#join(filename)

Returns a filename that has prepended the cache directory.

View source