workingsetcache

package
v1.36.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: Apache-2.0 Imports: 5 Imported by: 9

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
}

Cache is a cache for working set entries.

The cache evicts inactive entries after the given expireDuration. Recently accessed entries survive expireDuration.

Comparing to fastcache, this cache minimizes the required RAM size to values smaller than maxBytes.

func Load

func Load(filePath string, maxBytes int, expireDuration time.Duration) *Cache

Load loads the cache from filePath and limits its size to maxBytes and evicts inactive entires after expireDuration.

Stop must be called on the returned cache when it is no longer needed.

func New

func New(maxBytes int, expireDuration time.Duration) *Cache

New creates new cache with the given maxBytes size and the given expireDuration for inactive entries.

Stop must be called on the returned cache when it is no longer needed.

func (*Cache) Get

func (c *Cache) Get(dst, key []byte) []byte

Get appends the found value for the given key to dst and returns the result.

func (*Cache) GetBig

func (c *Cache) GetBig(dst, key []byte) []byte

GetBig appends the found value for the given key to dst and returns the result.

func (*Cache) Has

func (c *Cache) Has(key []byte) bool

Has verifies whether the cahce contains the given key.

func (*Cache) Reset

func (c *Cache) Reset()

Reset resets the cache.

func (*Cache) Save

func (c *Cache) Save(filePath string) error

Save safes the cache to filePath.

func (*Cache) Set

func (c *Cache) Set(key, value []byte)

Set sets the given value for the given key.

func (*Cache) SetBig

func (c *Cache) SetBig(key, value []byte)

SetBig sets the given value for the given key.

func (*Cache) Stop

func (c *Cache) Stop()

Stop stops the cache.

The cache cannot be used after the Stop call.

func (*Cache) UpdateStats

func (c *Cache) UpdateStats(fcs *fastcache.Stats)

UpdateStats updates fcs with cache stats.

Jump to

Keyboard shortcuts

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