Skip to content

Commit 3ef7fac

Browse files
committed
Create docstring for results_cache module
Signed-off-by: Jono Yang <jyang@nexb.com>
1 parent 7336b82 commit 3ef7fac

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

CHANGELOG.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ Next release
88
``licensedcode-data``.
99
https://github.com/aboutcode-org/scancode-toolkit/pull/5056
1010

11-
- Add experimental option for using cached results during scan time.
11+
- Add experimental option for using cached results during scan time. When the
12+
``--use-cached-results`` option is enabled in the ScanCode CLI, during scan
13+
time for a given Resource, we iterate through the active scanners and see if we
14+
have cached results for those already. If we do, we update our results with the
15+
cached data. If not, we add those scanners to a list of scanners to be run.
16+
After scanning, the cache is updated.
1217

1318
v33.0.0rc1 - 2026-05-14
1419
------------------------

src/scancode/results_cache.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,28 @@
1616
from scancode_config import results_cache_dir
1717

1818

19+
"""
20+
This module provides functions for the storage, retrieval, and organization of
21+
cached ScanCode scanner results.
22+
23+
The cache is stored in the ScanCode .cache directory. Depending on the setup,
24+
this could either be in the .cache directory in the user's home folder for a
25+
particular ScanCode version (in the case of running a ScanCode release) or in
26+
the .cache directory in the ScanCode directory (in the case of running a
27+
ScanCode git checkout).
28+
29+
In the .cache directory, the scanner results for a given Resource is stored in a
30+
directory whose path is created from the sha256 hexdigest of the Resource's
31+
content and its filename. Inside the results directory are JSON files with the
32+
name of scanners (license, copyright, etc.) and inside are the cached results.
33+
34+
When the --use-cached-results option is enabled in the ScanCode CLI, during scan
35+
time for a given Resource, we iterate through the active scanners and see if we
36+
have cached results for those already. If we do, we update our results with the
37+
cached data. If not, we add those scanners to a list of scanners to be run.
38+
After scanning, the cache is updated.
39+
"""
40+
1941
def hasher_from_chunks(chunks):
2042
"""
2143
Return a sha256 hasher loaded with `chunks`.

0 commit comments

Comments
 (0)