cache

package
v0.74.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package cache provides abstractions to allow the creation of concrete implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ObserveEviction added in v0.74.0

func ObserveEviction(ctx context.Context, attrs ...attribute.KeyValue)

func ObserveHit added in v0.74.0

func ObserveHit(ctx context.Context, attrs ...attribute.KeyValue)

ObserveHit increments the cache hit counter.

func ObserveMiss added in v0.74.0

func ObserveMiss(ctx context.Context, attrs ...attribute.KeyValue)

ObserveMiss increments the cache miss counter.

func SetupMetricsOnce added in v0.74.0

func SetupMetricsOnce()

SetupMetricsOnce initializes the cache counter.

func UseCaseAttribute added in v0.74.0

func UseCaseAttribute(useCase string) attribute.KeyValue

UseCaseAttribute returns an attribute.KeyValue with the use case.

Types

type Cache

type Cache interface {
	// Get a value based on a specific key. The call returns whether the  key exists or not.
	Get(ctx context.Context, key string) (interface{}, bool, error)
	// Purge the cache.
	Purge(ctx context.Context) error
	// Remove the key from the cache.
	Remove(ctx context.Context, key string) error
	// Set the value for the specified key.
	Set(ctx context.Context, key string, value interface{}) error
}

Cache interface that defines the methods required.

type TTLCache

type TTLCache interface {
	Cache
	// SetTTL sets the value of a specified key with a time to live.
	SetTTL(ctx context.Context, key string, value interface{}, ttl time.Duration) error
}

TTLCache interface adds support for expiring key value pairs.

Directories

Path Synopsis
Package lru implements a LRU based cache.
Package lru implements a LRU based cache.
Package redis contains the concrete implementation of a cache that supports TTL.
Package redis contains the concrete implementation of a cache that supports TTL.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳