cache

package
v2.26.5 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: CC0-1.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Caches

type Caches interface {
	Get(ctx context.Context, key string, typeDestination any, fallbackFn ...FallbackFn) error
	Del(ctx context.Context, key string) (int64, error)
	Set(ctx context.Context, key string, value any, expire ...int) error
	HSet(ctx context.Context, key, field string, value any, expire ...int) error
	HGet(ctx context.Context, key, field string, typeDestination any, fallbackFn ...FallbackFn) error
	HDel(ctx context.Context, key, field string) error
}

func GetCacheFromContext added in v2.21.2

func GetCacheFromContext(ctx context.Context) Caches

type FallbackFn added in v2.25.0

type FallbackFn func(ctx context.Context) (result any, expire int64, err error)

type Handler

type Handler interface {
	Get() redigo.Conn
	GetContext(context.Context) (redigo.Conn, error)
}

Handler handler for cache

type Options added in v2.4.1

type Options func(*RedisCfg)

func WithAddress added in v2.4.1

func WithAddress(address string) Options

func WithMaxActive added in v2.4.1

func WithMaxActive(maxActive int) Options

func WithMaxIdle added in v2.4.1

func WithMaxIdle(maxIdle int) Options

func WithMaxRetry added in v2.25.0

func WithMaxRetry(maxRetry int) Options

func WithPassword added in v2.4.4

func WithPassword(password string) Options

func WithTimeout added in v2.4.1

func WithTimeout(timeout int) Options

func WithUsername added in v2.4.4

func WithUsername(username string) Options

type RedisCfg

type RedisCfg struct {
	Address   string `yaml:"address"`
	Timeout   int    `yaml:"timeout"`
	MaxIdle   int    `yaml:"max_iddle"`
	MaxActive int    `yaml:"max_active"`
	Password  string `yaml:"password"`
	Username  string `yaml:"username"`
	MaxRetry  int
}

type Store

type Store struct {
	Pool Handler
	// contains filtered or unexported fields
}

Store object

func New

func New(options ...Options) *Store

func (*Store) Del

func (r *Store) Del(ctx context.Context, key string) (int64, error)

Del key value

func (*Store) Get

func (r *Store) Get(ctx context.Context, key string, typeDestination any, fallbackFn ...FallbackFn) error

Get string value

func (*Store) HDel added in v2.26.0

func (r *Store) HDel(ctx context.Context, key, field string) error

HGet set has map

func (*Store) HGet added in v2.26.0

func (r *Store) HGet(ctx context.Context, key, field string, typeDestination any, fallbackFn ...FallbackFn) error

HGet set has map

func (*Store) HSet

func (r *Store) HSet(ctx context.Context, key, field string, value any, expire ...int) error

HSet set has map

func (*Store) Set

func (r *Store) Set(ctx context.Context, key string, value any, expire ...int) error

Set ill be used to set the value

func (*Store) WrapToContext added in v2.21.2

func (r *Store) WrapToContext(ctx context.Context) context.Context

func (*Store) WrapToHandler added in v2.21.2

func (r *Store) WrapToHandler(next http.Handler) http.Handler

Jump to

Keyboard shortcuts

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