stash

package
Version: v0.0.0-...-810cf82 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2019 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Stash

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

Stash is a proxy for a chunks.Store, but it keeps Private Keys local, only saving them to the Store when Save is called.

func New

func New(bs chunks.Store) *Stash

New creates a new Stash.

func (*Stash) Clear

func (s *Stash) Clear()

Clear drops all the Private chunks held in this Stash. This is useful e.g. when the contents of a Blob are completely rewritten.

func (*Stash) Clone

func (s *Stash) Clone(ctx context.Context, key cas.Key, typ string, level uint8, size uint32) (cas.Key, *chunks.Chunk, error)

Clone is like Get but clones the chunk if it's not already private. Chunks that are already private are returned as-is.

A cloned chunk will have a buffer of size bytes. This is intended to use for re-inflating zero-trimmed chunks.

Modifying the returned chunk *will* cause the locally stored data to change. This is the intended usage of a stash.

func (*Stash) Drop

func (s *Stash) Drop(key cas.Key)

Drop forgets a Private chunk. The key may be reused, so caller must not remember the old key.

func (*Stash) Get

func (s *Stash) Get(ctx context.Context, key cas.Key, typ string, level uint8) (*chunks.Chunk, error)

Get returns a chunk either from the local stash, or from the Store (for Private keys).

For Private keys, modifying the returned chunk *will* cause the locally stored data to change. This is the intended usage of a stash.

func (*Stash) Save

func (s *Stash) Save(ctx context.Context, key cas.Key) (cas.Key, error)

Save the local Chunk to the Store.

On success, the old key becomes invalid.

Source Files

Jump to

Keyboard shortcuts

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