blobcache

package
v1.123.3 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package blobcache keeps copies of stored objects on local disk, keyed by ref and verified on every read.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is one store's blob directory. It is safe for concurrent use by several processes: entries are written next to their final name and renamed into place.

func Open

func Open(dir, storeID string, limit int64) (*Cache, error)

Open returns the cache of one store under dir. limit caps the cache in bytes when Sweep runs; 0 leaves it unbounded.

func (*Cache) Dir

func (c *Cache) Dir() string

Dir is the cache directory.

func (*Cache) Drop

func (c *Cache) Drop(ref *proto.Ref)

Drop removes the entry for ref.

func (*Cache) Get

func (c *Cache) Get(ref *proto.Ref) (*proto.Object, bool)

Get returns the cached object for ref after checking that it still hashes to it. A corrupt entry is removed.

func (*Cache) Put

func (c *Cache) Put(ref *proto.Ref, obj *proto.Object) error

Put stores the object under ref unless it is already there.

func (*Cache) Sweep

func (c *Cache) Sweep() (int, error)

Sweep removes the least recently used entries until the cache fits its limit and returns how many it removed.

Jump to

Keyboard shortcuts

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