cache

package
v0.0.0-...-0940e79 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoCache

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

func (*GoCache) Get

func (r *GoCache) Get(c context.Context, key string, _ any) (any, error)

func (*GoCache) Set

func (r *GoCache) Set(c context.Context, key string, value any, ttls time.Duration) error

func (*GoCache) Setup

func (o *GoCache) Setup(c context.Context, deps ...gobs.IService) error

func (*GoCache) Wrap

func (r *GoCache) Wrap(
	c context.Context,
	key string,
	_ any,
	callback func() (any, error),
	ttls time.Duration,
) (res any, err error)

type ICache

type ICache interface {
	Set(c context.Context, key string, value any, ttls time.Duration) error
	Get(c context.Context, key string, model any) (any, error)
	Wrap(c context.Context, key string, model any, callback func() (any, error), ttls time.Duration) (any, error)
}

func NewICache

func NewICache() ICache

type Redis

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

func (*Redis) Get

func (r *Redis) Get(c context.Context, key string, model any) (any, error)

func (*Redis) Init

func (o *Redis) Init(ctx context.Context) (*gobs.ServiceLifeCycle, error)

func (*Redis) Set

func (r *Redis) Set(c context.Context, key string, value any, ttls time.Duration) error

func (*Redis) Setup

func (o *Redis) Setup(c context.Context, deps ...gobs.IService) error

func (*Redis) Start

func (o *Redis) Start(ctx context.Context) error

func (*Redis) Stop

func (o *Redis) Stop(ctx context.Context) error

func (*Redis) Wrap

func (r *Redis) Wrap(
	c context.Context,
	key string,
	model any,
	callback func() (any, error),
	ttls time.Duration,
) (res any, err error)

type RedisConfig

type RedisConfig struct {
	Host     string `env:"REDIS_HOST" envDefault:"localhost"`
	Port     int    `env:"REDIS_PORT" envDefault:"6379"`
	Password string `env:"REDIS_PASSWORD" envDefault:""`
	DB       int    `env:"REDIS_DB" envDefault:"0"`
}

Jump to

Keyboard shortcuts

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