cache

package
v0.37.2 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: Apache-2.0 Imports: 10 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 {
	// contains filtered or unexported fields
}

func New

func New(c Config) *Cache

func (*Cache) Delete added in v0.0.33

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

func (*Cache) Discard added in v0.2.5

func (cache *Cache) Discard(key string)

func (*Cache) DiscardPrefix added in v0.2.5

func (cache *Cache) DiscardPrefix(prefix string) error

DiscardPrefix deletes all data that matches a certain prefix In both cache and database

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) GetOrCreate added in v0.0.37

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

func (*Cache) Lookup added in v0.0.37

func (cache *Cache) Lookup(key string) (interface{}, bool)

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) Sync added in v0.16.0

func (cache *Cache) Sync() error

func (*Cache) WriteBack added in v0.0.33

func (cache *Cache) WriteBack()

type Codec added in v0.0.40

type Codec interface {
	Serialize(w io.Writer, key string, value interface{}) error
	Deserialize(r io.Reader, key string) (interface{}, error)
	// New returns a new instance of the type. The method is
	// called by GetOrCreate when an item can not be found by
	// the given key.
	New(key string) interface{}
}

Codec is a shorthand of coder-decoder. A Codec implementation is responsible for type conversions and binary representation.

type Config added in v0.0.40

type Config struct {
	*badger.DB
	*Metrics
	Codec

	// Prefix for badger DB keys.
	Prefix string
	// TTL specifies number of seconds an item can reside in cache after
	// the last access. An obsolete item is evicted. Setting TTL to less
	// than a second disables time-based eviction.
	TTL time.Duration
}

type Metrics added in v0.0.38

type Metrics struct {
	MissesCounter     prometheus.Counter
	ReadsCounter      prometheus.Counter
	DBWrites          prometheus.Observer
	DBReads           prometheus.Observer
	WriteBackDuration prometheus.Observer
	EvictionsDuration prometheus.Observer
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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