cache

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// MetricsSubsystem is a subsystem shared by all metrics exposed by this
	// package.
	MetricsSubsystem = "ibcache"
)

Variables

This section is empty.

Functions

func NopMetricsProvider

func NopMetricsProvider() func(storeName string) *Metrics

NopMetricsProvider returns NopMetrics for each store

func PrometheusMetricsProvider

func PrometheusMetricsProvider(namespace string, labelsAndValues ...string) func(storeName string) *Metrics

PrometheusMetricsProvider returns PrometheusMetrics for each store

Types

type CommitKVStoreCache

type CommitKVStoreCache struct {
	types.CommitKVStore
	// contains filtered or unexported fields
}

CommitKVStoreCache implements an inter-block (persistent) cache that wraps a CommitKVStore. Reads first hit the internal ARC (Adaptive Replacement Cache). During a cache miss, the read is delegated to the underlying CommitKVStore and cached. Deletes and writes always happen to both the cache and the CommitKVStore in a write-through manner. Caching performed in the CommitKVStore and below is completely irrelevant to this layer.

func NewCommitKVStoreCache

func NewCommitKVStoreCache(store types.CommitKVStore, size int, metrics *Metrics) *CommitKVStoreCache

func (*CommitKVStoreCache) CacheWrap

func (ckv *CommitKVStoreCache) CacheWrap() types.CacheWrap

CacheWrap returns the inter-block cache as a cache-wrapped CommitKVStore.

func (*CommitKVStoreCache) Delete

func (ckv *CommitKVStoreCache) Delete(key []byte)

Delete removes a key/value pair from both the write-through cache and the underlying CommitKVStore.

func (*CommitKVStoreCache) Get

func (ckv *CommitKVStoreCache) Get(key []byte) []byte

Get retrieves a value by key. It will first look in the write-through cache. If the value doesn't exist in the write-through cache, the query is delegated to the underlying CommitKVStore.

func (*CommitKVStoreCache) Set

func (ckv *CommitKVStoreCache) Set(key, value []byte)

Set inserts a key/value pair into both the write-through cache and the underlying CommitKVStore.

type CommitKVStoreCacheManager

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

CommitKVStoreCacheManager maintains a mapping from a StoreKey to a CommitKVStoreCache. Each CommitKVStore, per StoreKey, is meant to be used in an inter-block (persistent) manner and typically provided by a CommitMultiStore.

func NewCommitKVStoreCacheManager

func NewCommitKVStoreCacheManager(size int, metricsProvider MetricsProvider) *CommitKVStoreCacheManager

func (*CommitKVStoreCacheManager) GetStoreCache

GetStoreCache returns a Cache from the CommitStoreCacheManager for a given StoreKey. If no Cache exists for the StoreKey, then one is created and set. The returned Cache is meant to be used in a persistent manner.

func (*CommitKVStoreCacheManager) Reset

func (cmgr *CommitKVStoreCacheManager) Reset()

Reset resets in the internal caches.

func (*CommitKVStoreCacheManager) Unwrap

Unwrap returns the underlying CommitKVStore for a given StoreKey.

type Metrics

type Metrics struct {
	InterBlockCacheSize   metrics.Gauge
	InterBlockCacheHits   metrics.Counter
	InterBlockCacheMisses metrics.Counter
}

Metrics contains metrics exposed by this package.

func NopMetrics

func NopMetrics() *Metrics

NopMetrics returns no-op Metrics.

func PrometheusMetrics

func PrometheusMetrics(namespace string, storeName string, labelsAndValues ...string) *Metrics

PrometheusMetrics returns Metrics build using Prometheus client library. Optionally, labels can be provided along with their values ("foo", "fooValue").

type MetricsProvider

type MetricsProvider func(storeName string) *Metrics

Jump to

Keyboard shortcuts

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