pub fn key(
    previous_key: &str,
    task: &Task,
    input_files_hash: &str,
    environment: &HashMap<String, String>,
) -> String {
    // Start with the previous key.
    let mut cache_key: String = previous_key.to_owned();

    // If there are no environment variables, no input paths, and no command to run, we can just use
    // the cache key from the previous task.
    if task.environment.is_empty() && task.input_paths.is_empty() && task.command.is_empty() {
        return cache_key;
    }

    // Incorporate the cache version.
    cache_key = combine(&cache_key, &format!("{}", CACHE_VERSION));

    // Environment variables
    let mut environment_hash = String::new();
    let mut variables = task.environment.keys().collect::<Vec<_>>();
    variables.sort();
    for variable in variables {
        // The variable name
        environment_hash = combine(&environment_hash, variable);

        // The value [ref:environment_valid]
        environment_hash = combine(&environment_hash, &environment[variable]);
    }
    cache_key = combine(&cache_key, &environment_hash);

    // Input paths and contents
    cache_key = combine(&cache_key, input_files_hash);

    // Location
    cache_key = combine(&cache_key, &task.location);

    // User
    cache_key = combine(&cache_key, &task.user);

    // Command
    cache_key = combine(&cache_key, &task.command);

    // We add this "toast-" prefix because Docker has a rule that tags cannot be 64-byte hexadecimal
    // strings. See this for more details: https://github.com/moby/moby/issues/20972
    // [tag:cache_prefix]
    format!("toast-{}", cache_key)
}
// Determine the cache key of a task based on the cache key of the previous task in the schedule (or
// the hash of the base image, if this is the first task).
Determine the cache key of a task based on the cache key of the previous task in the schedule (or
the hash of the base image, if this is the first task).
Determine the cache key of a task based on the cache key of the previous task in the schedule ( or the hash of the base image if this is the first task ) .
pub fn key(
    previous_key: &str,
    task: &Task,
    input_files_hash: &str,
    environment: &HashMap<String, String>,
) -> String {
    // Start with the previous key.
    let mut cache_key: String = previous_key.to_owned();
    // If there are no environment variables, no input paths, and no command to run, we can just use
    // the cache key from the previous task.
    if task.environment.is_empty() && task.input_paths.is_empty() && task.command.is_empty() {
        return cache_key;
    }
    // Incorporate the cache version.
    cache_key = combine(&cache_key, &format!("{}", CACHE_VERSION));
    // Environment variables
    let mut environment_hash = String::new();
    let mut variables = task.environment.keys().collect::<Vec<_>>();
    variables.sort();
    for variable in variables {
        // The variable name
        environment_hash = combine(&environment_hash, variable);
        // The value [ref:environment_valid]
        environment_hash = combine(&environment_hash, &environment[variable]);
    }
    cache_key = combine(&cache_key, &environment_hash);
    // Input paths and contents
    cache_key = combine(&cache_key, input_files_hash);
    // Location
    cache_key = combine(&cache_key, &task.location);
    // User
    cache_key = combine(&cache_key, &task.user);
    // Command
    cache_key = combine(&cache_key, &task.command);
    // We add this "toast-" prefix because Docker has a rule that tags cannot be 64-byte hexadecimal
    // strings. See this for more details: https://github.com/moby/moby/issues/20972
    // [tag:cache_prefix]
    format!("toast-{}", cache_key)
}
pub fn key ( previous_key : & str , task : & Task , input_files_hash : & str , environment : & HashMap < String , String > , ) -> String { // Start with the previous key. let mut cache_key : String = previous_key . to_owned ( ) ; // If there are no environment variables, no input paths, and no command to run, we can just use // the cache key from the previous task. if task . environment . is_empty ( ) && task . input_paths . is_empty ( ) && task . command . is_empty ( ) { return cache_key ; } // Incorporate the cache version. cache_key = combine ( & cache_key , & format ! ( " " CACHE_VERSION ) ) ; // Environment variables let mut environment_hash = String :: new ( ) ; let mut variables = task . environment . keys ( ) . collect :: < Vec < _ > > ( ) ; variables . sort ( ) ; for variable in variables { // The variable name environment_hash = combine ( & environment_hash , variable ) ; // The value [ref:environment_valid] environment_hash = combine ( & environment_hash , & environment [ variable ] ) ; } cache_key = combine ( & cache_key , & environment_hash ) ; // Input paths and contents cache_key = combine ( & cache_key , input_files_hash ) ; // Location cache_key = combine ( & cache_key , & task . location ) ; // User cache_key = combine ( & cache_key , & task . user ) ; // Command cache_key = combine ( & cache_key , & task . command ) ; // We add this "toast-" prefix because Docker has a rule that tags cannot be 64-byte hexadecimal // strings. See this for more details: https://github.com/moby/moby/issues/20972 // [tag:cache_prefix] format ! ( " " cache_key ) }
Determine the cache key of a task based on the cache key of the previous task in the schedule (or
the hash of the base image, if this is the first task).
Determine the cache key of a task based on the cache key of the previous task in the schedule ( or the hash of the base image if this is the first task ) .
previous_key
&str
task
&Task
input_files_hash
&str
environment
&HashMap<String, String>