cache

package
v0.0.0-...-18c2e1d Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound    = errors.New("not found")
	ErrInvalidSize = errors.New("invalid size")
)
View Source
var (
	ErrInvalidScheme = errors.New("invalid scheme")
)

Functions

func RegisterCache

func RegisterCache(scheme string, f NewCacheFunc)

Types

type Cache

type Cache interface {
	Put(ctx context.Context, kind EntryKind, hash string, size, offset int64) (io.WriteCloser, error)
	Get(ctx context.Context, kind EntryKind, hash string, offset, length int64) (io.ReadCloser, int64, error)
	Contains(ctx context.Context, kind EntryKind, hash string) (bool, int64, error)
}

func NewCacheFromURI

func NewCacheFromURI(ctx context.Context, uri string) (Cache, error)

func NewGatedCache

func NewGatedCache(cache Cache, maxConcurrentReads, maxConcurrentWrites int) (Cache, error)

func NewHedgedCache

func NewHedgedCache(cache Cache, timeout time.Duration) (Cache, error)

type EntryKind

type EntryKind string
const (
	AC  EntryKind = "ac"
	CAS EntryKind = "cas"
)

type GatedCache

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

func (*GatedCache) Contains

func (c *GatedCache) Contains(ctx context.Context, kind EntryKind, hash string) (bool, int64, error)

func (*GatedCache) Get

func (c *GatedCache) Get(ctx context.Context, kind EntryKind, hash string, offset, length int64) (io.ReadCloser, int64, error)

func (*GatedCache) Put

func (c *GatedCache) Put(ctx context.Context, kind EntryKind, hash string, size, offset int64) (io.WriteCloser, error)

type HedgedCache

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

func (*HedgedCache) Contains

func (c *HedgedCache) Contains(ctx context.Context, kind EntryKind, hash string) (bool, int64, error)

func (*HedgedCache) Get

func (c *HedgedCache) Get(ctx context.Context, kind EntryKind, hash string, offset, length int64) (io.ReadCloser, int64, error)

func (*HedgedCache) Put

func (c *HedgedCache) Put(ctx context.Context, kind EntryKind, hash string, size, offset int64) (io.WriteCloser, error)

type NewCacheFunc

type NewCacheFunc func(ctx context.Context, uri *url.URL) (Cache, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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