storage

package
v0.0.0-...-6f052a2 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package storage contains the interface that is used to store and retrieve cache entries

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound       = errors.New("entry not found")
	ErrBucketNotFound = errors.New("bucket not found")
	ErrEncoding       = errors.New("failed to encode cache entry")
	ErrDecoding       = errors.New("failed to decode cache entry")
)

Common errors

Functions

This section is empty.

Types

type CacheEntry

type CacheEntry struct {
	Value          []byte
	ExpirationTime time.Time
}

type CacheManager

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

CacheManager manages a single shared cache instance across the application. It ensures thread safety and guarantees only one cache instance exists.

func GetCacheManager

func GetCacheManager() *CacheManager

GetCacheManager returns the global cache manager instance.

func (*CacheManager) Close

func (m *CacheManager) Close() error

Close closes the managed cache instance.

func (*CacheManager) GetCache

func (m *CacheManager) GetCache() (CacheStorage, error)

GetCache returns the shared cache instance, creating it if needed. Thread-safe and ensures only one cache instance exists.

func (*CacheManager) Reset

func (m *CacheManager) Reset() error

Reset clears the manager state (useful for tests).

type CacheStorage

type CacheStorage interface {
	Get(ctx context.Context, key string) (CacheEntry, error)
	Set(ctx context.Context, key string, value CacheEntry) error
	Delete(ctx context.Context, key string) error
	Clear(ctx context.Context) error
	Close() error
}

func NewBoltCache

func NewBoltCache() (CacheStorage, error)

Jump to

Keyboard shortcuts

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