cache

package
v1.0.29 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 11 Imported by: 1 module, 1 package

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

This section is empty.

Variables

This section is empty.

Functions

func DeleteFromCache

func DeleteFromCache(ctx context.Context, store *CacheStore, key string)

func GetFromCache

func GetFromCache[T any](ctx context.Context, store *CacheStore, key string) (*T, bool)

func SetToCache

func SetToCache[T any](ctx context.Context, store *CacheStore, key string, data *T, expiration time.Duration)

Types

type CacheStats added in v1.0.16

type CacheStats struct {
	TotalKeys       int64     `json:"total_keys"`
	HitRate         float64   `json:"hit_rate"`
	MemoryUsed      int64     `json:"memory_used"`
	MemoryUsedHuman string    `json:"memory_used_human"`
	ExpiredKeys     int64     `json:"expired_keys"`
	LastCleanupTime time.Time `json:"last_cleanup_time"`
}

type CacheStore

type CacheStore struct {
	Redis  *redis.Client
	Logger logger.LoggerInterface
	// contains filtered or unexported fields
}

func NewCacheStore

func NewCacheStore(redisClient *redis.Client, logger logger.LoggerInterface, metrics observability.CacheMetricsInterface) *CacheStore

func (*CacheStore) ClearExpired added in v1.0.16

func (store *CacheStore) ClearExpired(ctx context.Context) (int64, error)

func (*CacheStore) GetRefCount added in v1.0.16

func (store *CacheStore) GetRefCount() int64

func (*CacheStore) GetStats added in v1.0.16

func (store *CacheStore) GetStats(ctx context.Context) (*CacheStats, error)

func (*CacheStore) InvalidateCache added in v1.0.16

func (store *CacheStore) InvalidateCache(ctx context.Context, pattern string) (int64, error)

Jump to

Keyboard shortcuts

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