localintervalcache

package
v0.0.0-...-3b12f0d Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 21 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
}

Cache implements the `nativeunwind.IntervalCache` interface. It stores its cache data in a local sub-directory of `CacheDirectory`. The cache evicts data based on a LRU policy, with usage order preserved across HA restarts. If the cache grows larger than maxSize bytes elements will be removed from the cache before adding new ones, starting by the element with the oldest access time. To keep the order of the LRU cache across restarts, the population of the LRU is based on the access time information of existing elements.

func New

func New(maxSize uint64) (*Cache, error)

New creates a new Cache using `path.Join(config.CacheDirectory(), cacheDirPathSuffix())` as the data directory for the cache. If that directory does not exist it will be created. However, `CacheDirectory` itself must already exist.

func (*Cache) GetAndResetHitMissCounters

func (c *Cache) GetAndResetHitMissCounters() (hit, miss uint64)

GetAndResetHitMissCounters retrieves the current hit and miss counters and resets them to 0.

func (*Cache) GetCurrentCacheSize

func (c *Cache) GetCurrentCacheSize() (uint64, error)

GetCurrentCacheSize returns the current size of all elements in the cache.

func (*Cache) GetIntervalData

func (c *Cache) GetIntervalData(exeID host.FileID, interval *sdtypes.IntervalData) error

GetIntervalData loads the interval data from the cache that is associated with `exeID` into `interval`.

func (*Cache) HasIntervals

func (c *Cache) HasIntervals(exeID host.FileID) bool

HasIntervals returns true if interval data exists in the cache for a file with the provided ID, or false otherwise.

func (*Cache) SaveIntervalData

func (c *Cache) SaveIntervalData(exeID host.FileID, interval *sdtypes.IntervalData) error

SaveIntervalData stores the provided `interval` that is associated with `exeID` in the cache.

Jump to

Keyboard shortcuts

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