cache

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

File represents a cache file.

func Create

func Create(path string, h hash.Hash, rsum, dsum []byte) (*File, error)

Create a new cache file with the default compression level.

func CreateLevel

func CreateLevel(path string, h hash.Hash, rsum, dsum []byte, level int) (*File, error)

CreateLevel creates a new cache file with the given compression level.

func Open

func Open(path string, h hash.Hash, rsum, dsum []byte) (*File, error)

Open a cache file for reading.

func (*File) Close

func (f *File) Close() error

Close the files and write the body hash sum to the header.

func (*File) Name

func (f *File) Name() string

Name returns the name of the file.

func (*File) Read

func (f *File) Read(p []byte) (int, error)

Read from the file through the flate.Reader.

func (*File) ReadOnly

func (f *File) ReadOnly() bool

ReadOnly returns true if the file is read only.

func (*File) Write

func (f *File) Write(p []byte) (int, error)

Write to the file through the flate.Writer.

type Header struct {
	RootSum []byte
	DataSum []byte
	BodySum []byte
}

Header represents a cache header.

func ReadHeader

func ReadHeader(r io.Reader, size int) (Header, error)

ReadHeader reads a header with the given hash from the reader.

func (Header) Validate

func (h Header) Validate(rsum, dsum, bsum []byte) error

Validate checks for the hash value integrity.

func (Header) WriteTo

func (h Header) WriteTo(w io.Writer) (int64, error)

WriteTo writes the hash values to the given io.Writer.

Jump to

Keyboard shortcuts

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