Cache API reference
Exports of @anymux/cache. Back to the module
Classes
CachedFileSystem
classWraps an IFileSystem and caches read operations. Write operations invalidate relevant cache entries.
class CachedFileSystem
constructor
constructorconstructor(options: CachedFileSystemOptions): CachedFileSystem
isImplemented
methodisImplemented(method: string): boolean
clearCache
methodclearCache(): void
readFile
methodreadFile(path: string, options?: { encoding?: BufferEncoding; flag?: string; } | BufferEncoding): Promise<Buffer | string>stat
methodstat(path: string, options?: { bigint?: false; }): Promise<Stats>stat
methodstat(path: string, options: { bigint: true; }): Promise<BigIntStats>stat
methodstat(path: string, options?: { bigint?: boolean; }): Promise<Stats | BigIntStats>readdir
methodreaddir(path: string, options?: { encoding?: BufferEncoding; withFileTypes?: false; recursive?: boolean; }): Promise<string[]>readdir
methodreaddir(path: string, options: { encoding?: BufferEncoding; withFileTypes: true; recursive?: boolean; }): Promise<Dirent[]>readdir
methodreaddir(path: string, options?: { encoding?: BufferEncoding; withFileTypes?: boolean; recursive?: boolean; }): Promise<string[] | Dirent[]>exists
methodexists(path: string): Promise<boolean>
access
methodaccess(path: string, mode?: number): Promise<void>
writeFile
methodwriteFile(path: string, data: Buffer | string | Uint8Array, options?: { encoding?: BufferEncoding; mode?: number; flag?: string; }): Promise<void>appendFile
methodappendFile(path: string, data: Buffer | string | Uint8Array, options?: { encoding?: BufferEncoding; mode?: number; flag?: string; }): Promise<void>unlink
methodunlink(path: string): Promise<void>
rename
methodrename(oldPath: string, newPath: string): Promise<void>
mkdir
methodmkdir(path: string, options?: { recursive?: boolean; mode?: number; }): Promise<string | undefined>rmdir
methodrmdir(path: string, options?: { maxRetries?: number; recursive?: boolean; retryDelay?: number; }): Promise<void>rm
methodrm(path: string, options?: { force?: boolean; maxRetries?: number; recursive?: boolean; retryDelay?: number; }): Promise<void>copyFile
methodcopyFile(src: string, dest: string, mode?: number): Promise<void>
lstat
methodlstat(path: string, options?: { bigint?: false; }): Promise<Stats>lstat
methodlstat(path: string, options: { bigint: true; }): Promise<BigIntStats>lstat
methodlstat(path: string, options?: { bigint?: boolean; }): Promise<Stats | BigIntStats>truncate
methodtruncate(path: string, len?: number): Promise<void>
utimes
methodutimes(path: string, atime: string | number | Date, mtime: string | number | Date): Promise<void>
chmod
methodchmod(path: string, mode: string | number): Promise<void>
chown
methodchown(path: string, uid: number, gid: number): Promise<void>
readlink
methodreadlink(path: string, options?: { encoding?: BufferEncoding; }): Promise<string>symlink
methodsymlink(target: string, path: string, type?: "dir" | "file" | "junction"): Promise<void>
link
methodlink(existingPath: string, newPath: string): Promise<void>
createReadStream
methodcreateReadStream(path: string, options?: { encoding?: BufferEncoding; start?: number; end?: number; }): ReadStreamcreateWriteStream
methodcreateWriteStream(path: string, options?: { encoding?: BufferEncoding; flags?: string; mode?: number; }): WriteStreamwatch
methodwatch(path: string, options?: { encoding?: BufferEncoding; persistent?: boolean; recursive?: boolean; }): FSWatcheropen
methodopen(path: string, flags?: string | number, mode?: number): Promise<IFileHandle>
opendir
methodopendir(path: string, options?: { encoding?: BufferEncoding; bufferSize?: number; recursive?: boolean; }): Promise<IDir>realpath
methodrealpath(path: string, options?: { encoding?: BufferEncoding; }): Promise<string>cp
methodcp(src: string, dest: string, options?: { dereference?: boolean; errorOnExist?: boolean; filter?: (src: string, dest: string) => boolean | Promise<boolean>; force?: boolean; mode?: number; preserveTimestamps?: boolean; recursive?: boolean; verbatimSymlinks?: boolean; }): Promise<void>mkdtemp
methodmkdtemp(prefix: string, options?: { encoding?: BufferEncoding; }): Promise<string>statfs
methodstatfs(path: string, options?: { bigint?: false; }): Promise<StatFs>statfs
methodstatfs(path: string, options: { bigint: true; }): Promise<BigIntStatFs>statfs
methodstatfs(path: string, options?: { bigint?: boolean; }): Promise<StatFs | BigIntStatFs>lutimes
methodlutimes(path: string, atime: string | number | Date, mtime: string | number | Date): Promise<void>
lchown
methodlchown(path: string, uid: number, gid: number): Promise<void>
lchmod
methodlchmod(path: string, mode: string | number): Promise<void>
init
methodinit(options?: { encoding?: string; }): Promise<void>MemoryCacheStrategy
classclass MemoryCacheStrategy
constructor
constructor<T = unknown>(defaultTtl?: number): MemoryCacheStrategy<T>
get
methodget(key: string): T | undefined
set
methodset(key: string, value: T, ttl?: number): void
delete
methoddelete(key: string): void
clear
methodclear(): void
Interfaces
CachedFileSystemOptions
interfaceinterface CachedFileSystemOptions
fs
propertyfs: IFileSystem
strategy
propertystrategy: CacheStrategy<unknown>
ttl
propertyttl: number
CacheStrategy
interfaceinterface CacheStrategy
get
methodget(key: string): T | undefined
set
methodset(key: string, value: T, ttl?: number): void
delete
methoddelete(key: string): void
clear
methodclear(): void