Skip to main content

cache_key

Function cache_key 

Source
pub fn cache_key(
    repo_owner: &str,
    repo_name: &str,
    file_path: &str,
    pattern_id: &str,
    matched_text: &str,
) -> String
Expand description

Generate a cache key for a security finding.

Creates a SHA-256 hash of the concatenated components: {repo_owner}/{repo_name}:{file_path}:{pattern_id}:{matched_text}

Uses incremental hashing to avoid allocating a large intermediate string, which is more memory-efficient when matched_text contains large code snippets.

This ensures that identical findings across scans are cached, while different contexts (repo, file, pattern, or code) produce unique keys.

§Arguments

  • repo_owner - Repository owner (e.g., “octocat”)
  • repo_name - Repository name (e.g., “hello-world”)
  • file_path - File path where finding was detected
  • pattern_id - Pattern ID that matched
  • matched_text - The matched code snippet

§Returns

A 64-character hexadecimal SHA-256 hash.