fast-fs-hash - v0.0.0-rc4
    Preparing search index...

    Interface FileHashCacheSession

    A file hash cache session holding an exclusive OS-level lock.

    Created by FileHashCache.open. Exposes what was read from disk as read-only properties. Pass payload values to write to override them; omitted fields preserve the old values.

    The lock is released by write (after writing), by close, or by the using disposable pattern.

    interface FileHashCacheSession {
        payloadValue0: number;
        payloadValue1: number;
        payloadValue2: number;
        payloadValue3: number;
        rootPath: string;
        status: CacheStatus;
        version: number;
        get busy(): boolean;
        get cache(): FileHashCache;
        get compressedPayloads(): readonly Buffer<ArrayBufferLike>[];
        get configChanged(): boolean;
        get disposed(): boolean;
        get fileCount(): number;
        get files(): readonly string[];
        get needsWrite(): boolean;
        get uncompressedPayloads(): readonly Buffer<ArrayBufferLike>[];
        get wouldNeedWrite(): boolean;
        "[dispose]"(): void;
        close(): void;
        resolve(signal?: AbortSignal | null): Promise<FileHashCacheEntries>;
        write(options?: FileHashCacheWriteOptions | null): Promise<boolean>;
    }
    Index

    Properties

    payloadValue0: number

    Payload f64 value (slot 0) read from disk. 0 when status is 'missing'.

    payloadValue1: number

    Payload f64 value (slot 1) read from disk. 0 when status is 'missing'.

    payloadValue2: number

    Payload f64 value (slot 2) read from disk. 0 when status is 'missing'.

    payloadValue3: number

    Payload f64 value (slot 3) read from disk. 0 when status is 'missing'.

    rootPath: string

    Root path that was active when this session was opened.

    status: CacheStatus

    Cache status determined at open time.

    version: number

    Cache version (u32) that was active when this session was opened.

    Accessors

    • get compressedPayloads(): readonly Buffer<ArrayBufferLike>[]

      LZ4-compressed opaque binary payloads read from disk. Empty array if none. Lazily decoded, zero-copy.

      Returns readonly Buffer<ArrayBufferLike>[]

    • get fileCount(): number

      Number of tracked files (from disk, or from the constructor when status is 'missing').

      Returns number

    • get files(): readonly string[]

      File list as absolute paths. When status is 'missing', reflects the files passed to the constructor. Lazily decoded from the on-disk representation.

      Returns readonly string[]

    • get needsWrite(): boolean

      true if the session holds the lock and the status indicates a write is needed.

      Returns boolean

    • get uncompressedPayloads(): readonly Buffer<ArrayBufferLike>[]

      Uncompressed opaque binary payloads read from disk — stored raw directly after the header and readable without decompressing the body. Empty array if none. Lazily decoded, zero-copy.

      Returns readonly Buffer<ArrayBufferLike>[]

    • get wouldNeedWrite(): boolean

      Check if a write is needed — either because the cache status indicates changes on disk, or because the cache configuration was modified since this session was opened.

      Equivalent to session.status !== 'upToDate' || session.configChanged.

      Returns boolean

    Methods

    • Release the exclusive lock and mark this session as disposed. Safe to call multiple times. If called while resolve or write is in progress, cancels the operation via the cancel flag and closes immediately.

      Returns void

    • Resolve all file entries — complete stat + hash for every tracked file.

      After open(), some entries may be only partially resolved (CacheOpen exits early on the first change). This method completes stat + hash for ALL files, then returns a FileHashCacheEntries snapshot with per-file metadata.

      Can be called before write(). The resolved data is reused by write. Cannot be called after write() or close(). Returns cached result on subsequent calls.

      Parameters

      • Optionalsignal: AbortSignal | null

        Optional AbortSignal to cancel the resolve phase.

      Returns Promise<FileHashCacheEntries>

      Readonly snapshot of all file entries.

    • Write the cache file and release the lock.

      Can only be called once per session. After write completes (success or failure), the session is disposed and the lock is released.

      Omitted user-value fields preserve the values read from disk. Config overrides (version, fingerprint, rootPath, files) are applied to the parent FileHashCache before writing.

      Parameters

      Returns Promise<boolean>

      true if the write succeeded, false on lock failure.