cachefs

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package cachefs implements a wrapper that caches filesystem actions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrap

func Wrap(e fs.Entry, cacher DirectoryCacher) fs.Entry

Wrap returns an Entry that wraps another Entry and caches directory reads.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache maintains in-memory cache of recently-read data to speed up filesystem operations.

func NewCache

func NewCache(options *Options) *Cache

NewCache creates filesystem cache.

func (*Cache) IterateEntries added in v0.11.0

func (c *Cache) IterateEntries(ctx context.Context, d fs.Directory, w EntryWrapper, callback func(context.Context, fs.Entry) error) error

IterateEntries reads the contents of a provided directory using ObjectID of a directory (if any) to cache the results. The given callback is invoked on each item in the directory.

type DirectoryCacher

type DirectoryCacher interface {
	IterateEntries(ctx context.Context, d fs.Directory, w EntryWrapper, callback func(context.Context, fs.Entry) error) error
}

DirectoryCacher reads and potentially caches directory entries for a given directory.

type EntryWrapper added in v0.9.0

type EntryWrapper func(entry fs.Entry) fs.Entry

EntryWrapper allows an fs.Entry to be modified before inserting into the cache.

type Loader

type Loader func(ctx context.Context) ([]fs.Entry, error)

Loader provides data to be stored in the cache.

type Options

type Options struct {
	MaxCachedDirectories int
	MaxCachedEntries     int
}

Options specifies behavior of filesystem Cache.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL