cache

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright (c) Microsoft Corporation. Licensed under the Apache License, Version 2.0.

Copyright (c) Microsoft Corporation. Licensed under the Apache License, Version 2.0.

Copyright (c) Microsoft Corporation. Licensed under the Apache License, Version 2.0.

Index

Constants

This section is empty.

Variables

View Source
var (
	// FilesCacheMaxCost is the capacity of the files cache in any unit.
	FilesCacheMaxCost int64 = 4 * 1024 * 1024 * 1024 // 4 Gib

	// MemoryCacheMaxCost is the capacity of the memory cache in any unit.
	MemoryCacheMaxCost int64 = 1 * 1024 * 1024 * 1024 // 1 Gib

	// Path is the path to the cache directory.
	Path string = "/tmp/distribution/p2p/cache"
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Size gets the size of the file.
	Size(path string) (int64, bool)

	// PutSize sets size of the file.
	PutSize(path string, length int64) bool

	// Exists checks if the given chunk of the file is already cached.
	Exists(name string, offset int64) bool

	// GetOrCreate gets the cached value if available, otherwise downloads the file.
	GetOrCreate(name string, offset int64, count int, fetch func() ([]byte, error)) ([]byte, error)
}

Cache describes the cache of files.

func New

func New(ctx context.Context) Cache

New creates a new cache of files.

Jump to

Keyboard shortcuts

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