Classes
Cache
Defined in: index.ts:66
Extends
LRUCache<string,Buffer,CacheFetchContext>
Constructors
new Cache()
new Cache(options): CacheDefined in: index.ts:94
Parameters
options
Returns
Overrides
LRUCache< string, Buffer, CacheFetchContext>.constructorProperties
[toStringTag]
[toStringTag]: string = '@vltpkg/cache.Cache';Defined in: index.ts:72
Overrides
LRUCache.[toStringTag]onDiskDelete()?
optional onDiskDelete: (path, key, deleted) => any;Defined in: index.ts:77
Parameters
path
string
key
string
deleted
boolean
Returns
any
onDiskWrite()?
optional onDiskWrite: (path, key, data) => any;Defined in: index.ts:76
Parameters
path
string
key
string
data
Buffer
Returns
any
Accessors
pending
Get Signature
get pending(): Promise<BooleanOrVoid>[]Defined in: index.ts:82
A list of the actions currently happening in the background
Returns
Promise<BooleanOrVoid>[]
defaultMax
Get Signature
get static defaultMax(): numberDefined in: index.ts:90
By default, cache up to 1000 items in memory. Disk cache is unbounded.
Returns
number
Methods
[asyncIterator]()
asyncIterator: AsyncGenerator< [string, Buffer<ArrayBufferLike>], void, void>Defined in: index.ts:152
Returns
AsyncGenerator<[string, Buffer<ArrayBufferLike>], void,
void>
[iterator]()
iterator: Generator<[string, Buffer<ArrayBufferLike>], void>Defined in: index.ts:184
Returns
Generator<[string, Buffer<ArrayBufferLike>], void>
Overrides
LRUCache.[iterator]delete()
delete( key, fromDisk, integrity?): booleanDefined in: index.ts:205
Pass true as second argument to delete not just from the in-memory
cache, but the disk backing as well.
Parameters
key
string
fromDisk
boolean = false
integrity?
`sha512-${string}`
Returns
boolean
Overrides
LRUCache.deletefetchSync()
fetchSync(key, opts?): undefined | Buffer<ArrayBufferLike>Defined in: index.ts:307
Read synchronously from the fs cache storage if not already in memory.
Parameters
key
string
opts?
FetchOptions<string,
Buffer<ArrayBufferLike>,
CacheFetchContext>
Returns
undefined | Buffer<ArrayBufferLike>
integrityPath()
integrityPath(integrity?): undefined | stringDefined in: index.ts:289
given an SRI sha512 integrity string, get the path on disk that is hard-linked to the value.
Parameters
integrity?
`sha512-${string}`
Returns
undefined | string
path()
path(key?): stringDefined in: index.ts:282
given a key, figure out the path on disk where it lives
Parameters
key?
string
Returns
string
promise()
promise(): Promise<void>Defined in: index.ts:273
Resolves when there are no pending writes to the disk cache
Returns
Promise<void>
set()
set( key, val, options?): CacheDefined in: index.ts:235
Sets an item in the memory cache (like LRUCache.set), and schedules
a background operation to write it to disk.
Use the CacheOptions#onDiskWrite method to know exactly when this
happens, or await cache.promise() to defer until all pending actions
are completed.
The noDiskWrite option can be set to prevent it from writing back to
the disk cache. This is almost never relevant for consumers, and is
used internally to prevent the write at the end of fetch() from
excessively writing over a file we just read from.
Parameters
key
string
val
Buffer
options?
SetOptions<string,
Buffer<ArrayBufferLike>,
CacheFetchContext> & object
Returns
Overrides
LRUCache.setwalk()
walk(): AsyncGenerator<[string, Buffer<ArrayBufferLike>], void, unknown>Defined in: index.ts:133
Walk over all the items cached to disk (not just in memory). Useful for cleanup, pruning, etc.
Implementation for for await to walk over entries.
Returns
AsyncGenerator<[string, Buffer<ArrayBufferLike>], void,
unknown>
walkSync()
walkSync(): Generator<[string, Buffer<ArrayBufferLike>], void, unknown>Defined in: index.ts:163
Synchronous form of Cache.walk()
Returns
Generator<[string, Buffer<ArrayBufferLike>], void,
unknown>
Type Aliases
BooleanOrVoid
type BooleanOrVoid = boolean | voidDefined in: index.ts:53
CacheFetchContext
type CacheFetchContext = | { integrity: Integrity } | undefinedDefined in: index.ts:20
CacheOptions
type CacheOptions = { [k in keyof LRUCache.Options< string, Buffer, CacheFetchContext >]?: LRUCache.Options<string, Buffer, CacheFetchContext>[k]} & objectDefined in: index.ts:26
Type declaration
fetchMethod?
optional fetchMethod: undefined;fetchMethod may not be provided, because this cache forces its own read-from-disk as the fetchMethod
onDiskDelete()?
optional onDiskDelete: (path, key, deleted) => any;called whenever an item is deleted with cache.delete(key, true)
Deletes of the in-memory data do not trigger this method.
Parameters
path
string
key
string
deleted
boolean
Returns
any
onDiskWrite()?
optional onDiskWrite: (path, key, data) => any;called whenever an item is written to disk.
Parameters
path
string
key
string
data
Buffer
Returns
any
path
path: stringfolder where items should be stored to disk