cache

package
v2.99.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Module for fx.

Functions

func Get

func Get[T any](ctx context.Context, key string) (*T, bool, error)

Get a value from key.

func NewCache

func NewCache(params CacheParams) cacher.Cache

NewCache from config.

func Persist

func Persist[T any](ctx context.Context, key string, value *T, ttl time.Duration) error

Persist a value to the key with a TTL.

func Register

func Register(c cacher.Cache)

Register the cache.

Types

type Cache

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

Cache allows marshaling and compressing items to the cache.

func (*Cache) Close

func (c *Cache) Close(_ context.Context) error

Close the cache.

func (*Cache) Get

func (c *Cache) Get(_ context.Context, key string, value any) (bool, error)

Get a cached value.

func (*Cache) Persist

func (c *Cache) Persist(_ context.Context, key string, value any, ttl time.Duration) error

Persist a value with key and TTL.

func (*Cache) Remove

func (c *Cache) Remove(_ context.Context, key string) (bool, error)

Remove a cached key.

type CacheParams added in v2.50.0

type CacheParams struct {
	di.In
	Lifecycle  di.Lifecycle
	Config     *config.Config
	Encoder    *encoding.Map
	Pool       *sync.BufferPool
	Compressor *compress.Map
	Driver     driver.Driver
	Tracer     *tracer.Tracer
	Logger     *logger.Logger
	Meter      *metrics.Meter
}

CacheParams for cache.

Directories

Path Synopsis
telemetry

Jump to

Keyboard shortcuts

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