fscache

package
v18.9.10+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	Get(id string) (string, error)
	Remove(id string) error
}

Backend is a backing implementation for FSCache

func NewNaiveCacheBackend

func NewNaiveCacheBackend(root string) Backend

NewNaiveCacheBackend is a basic backend implementation for fscache

type CachePolicy

type CachePolicy struct {
	Priority int
	LastUsed time.Time
}

CachePolicy defines policy for keeping a resource in cache

type FSCache

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

FSCache allows syncing remote resources to cached snapshots

func NewFSCache

func NewFSCache(opt Opt) (*FSCache, error)

NewFSCache returns new FSCache object

func (*FSCache) Close

func (fsc *FSCache) Close() error

Close stops the gc and closes the persistent db

func (*FSCache) DiskUsage

func (fsc *FSCache) DiskUsage(ctx context.Context) (int64, error)

DiskUsage reports how much data is allocated by the cache

func (*FSCache) Prune

func (fsc *FSCache) Prune(ctx context.Context) (uint64, error)

Prune allows manually cleaning up the cache

func (*FSCache) RegisterTransport

func (fsc *FSCache) RegisterTransport(id string, transport Transport) error

RegisterTransport registers a new transport method

func (*FSCache) SyncFrom

func (fsc *FSCache) SyncFrom(ctx context.Context, id RemoteIdentifier) (builder.Source, error)

SyncFrom returns a source based on a remote identifier

type GCPolicy

type GCPolicy struct {
	MaxSize         uint64
	MaxKeepDuration time.Duration
}

GCPolicy defines policy for garbage collection

type Opt

type Opt struct {
	Backend  Backend
	Root     string // for storing local metadata
	GCPolicy GCPolicy
}

Opt defines options for initializing FSCache

type RemoteIdentifier

type RemoteIdentifier interface {
	Key() string
	SharedKey() string
	Transport() string
}

RemoteIdentifier identifies a transfer request

type Transport

type Transport interface {
	Copy(ctx context.Context, id RemoteIdentifier, dest string, cs filesync.CacheUpdater) error
}

Transport defines a method for syncing remote data to FSCache

Jump to

Keyboard shortcuts

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