cache

package
v0.0.0-...-084b64f Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(val interface{}) (string, error)
  • Compute a sha1 hash of any object *
  • The sha1 is cryptographically broken and hence this hasher should not be
  • used for security. Rather it's intended to compute hashes that can be used
  • as keys in a cache.

Types

type Cache

type Cache interface {
	Get(string) (CacheEntry, bool)
	Set(string, CacheEntry)
}

func NewCache

func NewCache(cachesize uint64) Cache
  • Return a new cache with maxsize of 'cachesize' (megabytes) *
  • Requesting a new cache with size zero will return a 'NoCache' which behaves
  • like a cache, but does not cache anything. I.e. it will always be empty and
  • will have a 100% cache misses.

type CacheEntry

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

func NewCacheEntry

func NewCacheEntry(data [][]byte, metadata []byte) CacheEntry

func (*CacheEntry) Data

func (c *CacheEntry) Data() [][]byte

func (*CacheEntry) Metadata

func (c *CacheEntry) Metadata() []byte

func (*CacheEntry) Size

func (c *CacheEntry) Size() int

type NoCache

type NoCache struct{}

func NewNoCache

func NewNoCache() *NoCache

func (*NoCache) Get

func (c *NoCache) Get(key string) (CacheEntry, bool)

func (*NoCache) Set

func (c *NoCache) Set(key string, val CacheEntry)

type RistrettoCache

type RistrettoCache struct {
	ristretto.Cache
}

func NewRistrettoCache

func NewRistrettoCache(cacheSize uint64) *RistrettoCache

func (*RistrettoCache) Get

func (c *RistrettoCache) Get(key string) (val CacheEntry, hit bool)

func (*RistrettoCache) Set

func (c *RistrettoCache) Set(key string, val CacheEntry)

Jump to

Keyboard shortcuts

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