cache

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {

	// Bytes serializes objects before they go into storage. Users are required to define this one
	Bytes func(k string, v interface{}) ([]byte, error)
	// FromBytes deserializes object coming from storage. Users are required to define this one
	FromBytes func(k string, v []byte) (interface{}, error)
	// New creates a new object when there's no object in cache or storage. Optional
	New func(k string) interface{}
	// contains filtered or unexported fields
}

func New

func New(db *badger.DB, prefix, humanReadableName string) *Cache

func (*Cache) Delete added in v0.0.33

func (cache *Cache) Delete(key string) error

func (*Cache) Evict added in v0.0.33

func (cache *Cache) Evict(percent float64)

Evict performs cache evictions. The difference between Evict and WriteBack is that evictions happen when cache grows above allowed threshold and write-back calls happen constantly, making pyroscope more crash-resilient. See https://github.com/pyroscope-io/pyroscope/issues/210 for more context

func (*Cache) Flush

func (cache *Cache) Flush()

func (*Cache) Get

func (cache *Cache) Get(key string) (interface{}, error)

func (*Cache) Len added in v0.0.33

func (cache *Cache) Len() int

func (*Cache) Put

func (cache *Cache) Put(key string, val interface{})

func (*Cache) Size added in v0.0.33

func (cache *Cache) Size() uint64

func (*Cache) WriteBack added in v0.0.33

func (cache *Cache) WriteBack()

See Evict for more information on this

Jump to

Keyboard shortcuts

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