synology_apm_repo.sdk.storage.dircache module¶
DirCache — the directory-listing cache behind resolve_seq_file’s
“logical name -> [physical names]” lookups for per-generation files
(.buk, .inf, .fgp, .ref, …).
Re-listing a directory on every lookup would make an export touching a few
hundred buckets do O(n^2) scans (hundreds of paginated list calls on object
storage), so each opened repository keeps DirCache instances for its
lifetime, bounded by count; invalidate() (reached through
CacheManager) forces a re-scan.
generations.py’s db/<name> generation selection lists through this
cache’s flat listdir (DedupRepo’s fixed-directory instance), so the
several db/<name> resolutions of one repository share three listings.
- synology_apm_repo.sdk.storage.dircache.split_seq_suffix(name)¶
Split a trailing
.<digits>sequence-id suffix offname(FORMAT-SPEC.md: Sequence-id suffix mechanism). Returns(name, None)if there is none. Only the last dot-segment counts:"132.buk.1"->("132.buk", 1),"132.buk"->("132.buk", None).
- class synology_apm_repo.sdk.storage.dircache.DirCache(store, *, maxsize=256)¶
Bases:
objectBounded cache of directory listings, keyed by store-relative directory path. One listing per cached directory; the grouped index and any sizes the backend reported with it are kept, and
listdiris derived from them, so a directory costs one entry however it is asked for.maxsizebounds the directories held (LRU). Tasks racing on the same cold directory share one listing.- async listdir(dir_path)¶
The entry names
store.listdir(dir_path)reports, sorted, from the cached listing.
- async grouped(dir_path)¶
{logical_name: [physical_name, ...]}fordir_path.logical_nameis the entry with any sequence-id suffix stripped (split_seq_suffix).
- async entry_sizes(dir_path)¶
Every entry name in
dir_pathwith the size the listing reported for it (None: no size, or a directory), from the cached listing.
- async size_of(dir_path, name)¶
The size of
name(a physical entry name) indir_pathas the listing itself reported it, with no extra request;Nonewhen the listing had no size for it,nameis a directory, or it is absent.
- stats()¶
Counters of the underlying directory cache.
- invalidate(dir_path=None)¶
Drop the cached entry for
dir_path(or everything, if omitted).