cachefs

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 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) Readdir

func (c *Cache) Readdir(ctx context.Context, d fs.Directory, w EntryWrapper) (fs.Entries, error)

Readdir reads the contents of a provided directory using ObjectID of a directory (if any) to cache the results.

type DirectoryCacher

type DirectoryCacher interface {
	Readdir(ctx context.Context, d fs.Directory, w EntryWrapper) (fs.Entries, 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.Entries, 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