Metreeca Gear
    Preparing search index...

    Function createFileCache

    • Creates a file cache.

      Values are held as files under a folder of the working space, so that content outlives the process that stored it and is shared by every job anchored to the same space: a run repeated over the same keys is served from the file system rather than from the source the content was taken from.

      Called with no options, the cache retains every value until it is removed; given a time to live, values left unused for longer are dropped; given a byte budget, values beyond it are dropped in least recently used order, so that a cache left in place neither keeps serving content the source has since moved on from nor grows without bound.

      Every get and put counts as a use, restarting the time to live of the value and making it the most recently used one: a value is dropped only once left untouched for a whole time to live, or once every other retained value has been used more recently. Retention is enforced on access rather than on a timer, so an expired value is never handed out, and the room it held, like the room freed by a removal, is reclaimed on the next get or put under any key.

      Parameters

      • options: { path?: string; ttl?: number; bytes?: number } = {}

        The cache options, all optional

        • Optional Readonlypath?: string

          The path of the folder holding the stored values, resolved against the base path of the execution the cache is created in, as getPath defines; defaults to cache

        • Optional Readonlyttl?: number

          The number of milliseconds a value is retained for after its last use, dropping it once they elapse; a value less than or equal to 0 retains values indefinitely, as the default does

        • Optional Readonlybytes?: number

          The total number of value bytes to be retained, dropping the least recently used values beyond that, a value exceeding the budget on its own included; a value less than or equal to 0 leaves the cache unbounded, as the default does

      Returns Bucket

      A fresh, immutable Bucket holding values as files under options.path

      If created outside an execution, as service defines

      While storing or retrieving a value, if the folder holding the cache is not accessible or is a plain file