DorsalCache
dorsal.file.cache.DorsalCache
Manages the local SQLite cache for file metadata.
Source code in venv/lib/python3.12/site-packages/dorsal/file/cache/dorsal_cache.py
clear
Close the connection and deletes the entire database file.
Source code in venv/lib/python3.12/site-packages/dorsal/file/cache/dorsal_cache.py
close
Commit any pending changes and close the connection.
Source code in venv/lib/python3.12/site-packages/dorsal/file/cache/dorsal_cache.py
connect
Establishes a connection to the SQLite database and initializes the schema.
Source code in venv/lib/python3.12/site-packages/dorsal/file/cache/dorsal_cache.py
export
Exports the contents of the cache to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_path
|
Path
|
The path to save the exported file. |
required |
format
|
Literal['json', 'json.gz']
|
The desired output format. Defaults to "json.gz". |
'json.gz'
|
include_records
|
bool
|
Whether to include the full metadata records. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
int
|
The total number of records exported. |
Source code in venv/lib/python3.12/site-packages/dorsal/file/cache/dorsal_cache.py
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 | |
get_hash
Efficiently retrieves a specific hash for a cached file if the cache is valid.
Source code in venv/lib/python3.12/site-packages/dorsal/file/cache/dorsal_cache.py
get_record
Retrieves a record, decompressing it if necessary.
Source code in venv/lib/python3.12/site-packages/dorsal/file/cache/dorsal_cache.py
optimize
Runs a full maintenance routine on the cache.
Source code in venv/lib/python3.12/site-packages/dorsal/file/cache/dorsal_cache.py
prune
Prunes the cache by removing stale records.
Source code in venv/lib/python3.12/site-packages/dorsal/file/cache/dorsal_cache.py
summary
Provides a summary of the cache's current state.
Source code in venv/lib/python3.12/site-packages/dorsal/file/cache/dorsal_cache.py
upsert_hash
Inserts or updates a single hash, correctly handling and invalidating existing full records if they are stale.
Source code in venv/lib/python3.12/site-packages/dorsal/file/cache/dorsal_cache.py
upsert_record
Inserts or replaces a record, respecting the compression setting.
Source code in venv/lib/python3.12/site-packages/dorsal/file/cache/dorsal_cache.py
vacuum
Rebuilds the database file, reclaiming free space.