IF Commons GitHub

physical/cache

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0004-anyfs-posix-physical FR-006

The read cache of the view: whole objects, kept by their path and their revision, so that an object read again while it has not changed costs a stat and no bytes. A revision names bytes, so an entry can never be stale: a changed object has another revision and another key. The cache holds at most the bytes the policy gives and drops the oldest first; an object larger than the cache is not kept.

import { ReadCache } from "./cache.ts";
const cache = new ReadCache(1024);
cache.put("a", "sha256:1", new Uint8Array(10));
cache.get("a", "sha256:1")?.length; // 10

Source: commons/anyfs-posix/src/physical/cache.ts

1 of 2 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

physical.ReadCacheclassno test imports it
class ReadCache

The cache.

MemberTypeWhat it is
get(path: string, rev: string) => Uint8Array<ArrayBufferLike> | undefinedThe bytes of an object at a revision, as a copy the caller may change, or nothing.
put(path: string, rev: string, bytes: Uint8Array<ArrayBufferLike>) => voidKeeps the bytes of an object at a revision, dropping the oldest until they fit.
bytesnumberHow many bytes it holds.
ReadCacheclass
class ReadCache

The cache.

MemberTypeWhat it is
get(path: string, rev: string) => Uint8Array<ArrayBufferLike> | undefinedThe bytes of an object at a revision, as a copy the caller may change, or nothing.
put(path: string, rev: string, bytes: Uint8Array<ArrayBufferLike>) => voidKeeps the bytes of an object at a revision, dropping the oldest until they fit.
bytesnumberHow many bytes it holds.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.