Documentation ¶
Overview ¶
Copyright (c) Microsoft Corporation. Licensed under the MIT License.
Copyright (c) Microsoft Corporation. Licensed under the MIT License.
Copyright (c) Microsoft Corporation. Licensed under the MIT License.
Copyright (c) Microsoft Corporation. Licensed under the MIT License.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // FilesCacheMaxCost is the capacity of the files cache. FilesCacheMaxCost int64 = 4 * 1024 * 1024 * 1024 // 4 Gib // MemoryCacheMaxCost is the capacity of the memory cache. MemoryCacheMaxCost int64 = 1 * 1024 * 1024 * 1024 // 1 Gib // Path is the path to the cache directory. Path string = "/tmp/distribution/peerd/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 a cache of files.
type SyncMap ¶
type SyncMap struct {
// contains filtered or unexported fields
}
SyncMap is a map that can be safely accessed concurrently.
func NewSyncMap ¶
NewSyncMap creates a new SyncMap with the specified maximum number of entries. If the maximum number of entries is less than or equal to 0, it will be set to 1.
func (*SyncMap) Delete ¶
Delete removes the entry with the specified key from the SyncMap. If the key does not exist, this method does nothing.
func (*SyncMap) Get ¶
Get retrieves the value associated with the given key from the SyncMap. It returns the value and a boolean indicating whether the key was found.